Test and Measurement Forum

Useful looking compiler warning from PS2000con.c

Post your C and C++ discussions here

Useful looking compiler warning from PS2000con.c

Postby Sonander » Thu Aug 26, 2010 9:21 am

In Microsoft Visual Studio 2010 when I compile PS2000con.c it came up with a surprisingly relevant looking warning.

Against this line
short input_ranges [PS2000_MAX_RANGES] = {10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000};

It reports
Warning 1 warning C4309: 'initializing' : truncation of constant value

Which seems fair and valid. 50,000 isn't going to fit into a signed short int on a 32 bit system. That's going to do ugly things to subsequent interpretation of the top voltage range.

I changed the definition to int and suggest Picotech do the same.
Posts: 8
Joined: Mon Jan 05, 2009 10:13 pm
Location: Letchworth, England

Re: Useful looking compiler warning from PS2000con.c

Postby Robin » Thu Aug 26, 2010 12:47 pm


Well spotted. It will be changed in the next SDK release.

Older versions of Visual Studio don't seem to give a warning.

Advanced User
Advanced User
Posts: 558
Joined: Fri Sep 19, 2008 10:17 am

Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests