LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Reporting error when using sizeof to get an integer length

That may be.

 

But you don't get a warning with the native CVI compiler when you coerce an int to a char.

 

char cByte;

int     i = 1;

 

cByte = i;  // no warning here

 

But you will get a warning for this on MSVCPP or the Intel compilers, for example.

 

Menchar

0 Kudos
Message 11 of 14
(1,005 Views)

These CVI warnings only apply to coercions between 64-bit integers/pointers and 32-bit integers. They're new for 2009, and they're intended to help in the porting of 32-bit code to 64-bit code.

 

Coercing an int to a char is not a new situation and is not relevant for porting code to 64-bit, and so these warnings did not extend to that type of coercion. The reason being that we didn't want to suddenly start littering with warnings existing code, which previously had compiled without any warnings.

 

Luis

0 Kudos
Message 12 of 14
(994 Views)

You could add the warnings for int -> char loss of precision at a new warning level that the developer can select in build settings.

 

If you compile most anything in CVI with MSVCPP or the Intel compiler, you typically get hundreds of warnings, most of them in header files that NI wrote.

 

While I'm not going to go in and re-write NI's header files, you also get warnings for developer code that I would argue may be quite relevant, depending on the application and how good you want it to be.

 

signed / unsigned integer comparisons are an example, and the previously cited loss of precision int -> char is another.    The newer compilers are getting really good at finding ambiguous code.

 

Then again, you could argue that if you need to be warned about this, hook up MSVCPP or Intel CPP release compiler and see for yourself.

 

Menchar

0 Kudos
Message 13 of 14
(973 Views)

We didn't add those warnings because currently there is no concept of warning levels in the CVI compiler. Once something along those lines exists, then it'll become easier to add additional warnings.

 

Luis

0 Kudos
Message 14 of 14
(946 Views)