Useful looking compiler warning from PS2000con.c

Post your C and C++ discussions here
Post Reply
Sonander
User
User
Posts: 8
Joined: Mon Jan 05, 2009 10:13 pm
Location: Letchworth, England

Useful looking compiler warning from PS2000con.c

Post by Sonander »

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.

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

Re: Useful looking compiler warning from PS2000con.c

Post by Robin »

Hi

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

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

Robin

Post Reply