LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

New Warning messages passing from CVI 2013 to CVI 2019

Hi,

I've just changed my computer and just installed the new CVI release: 2019.

So far I was using CVI 2013 and I was worried about the possible issues upgrading the IDE, due to the complexity of some projects I've developed and my company uses in the production lines.

I've been so happy when, after launching the Build on the most complex project, I've got two new Warnings only.

The first one is about the cast from function call.

Looking at the screen shot below, it seems that recasting a variable form int to double is allowed "(double)iDrvFreq", while recasting the result of a function call from int to double "(double)rand()" generates a warning.

CastFromFunctionCall.JPG

The second is about illegal character encoding, underlined in red in the following screen shot.

IllegalCharacterEncoding.JPG

It is related to a string where I'm showing the result of an acceleration measurement using the correct M.U.

My question is: CVI 2013 didn't give me any warning message and the application worked fine, should I expect any different behavior of the application generated by CVI 2019? If yes, any appreciable suggestions?

 

Thank you

Sergio

0 Kudos
Message 1 of 5
(2,114 Views)

Hi Sergio,
the warnings you get shouldn't affect the behavior of your application, however here are some tips I can give you about it.

  • The second warning (-Winvalid-source-encoding) warns about illegal character encoding in character or string literals. The illegal character seems to be the exponent ²; if you use the Alt code instead (in this case, Alt+253) this issue should disappear. You can refer to this document, which mentions non-printable characters, but I guess it can be extended to any special character and symbol.
  • Let's take care of the first warning (-Wbad-function-cast), which warns about casting a function call to a non-matching type. If your guess is correct - «recasting a variable form int to double is allowed "(double)iDrvFreq", while recasting the result of a function call from int to double "(double)rand()" generates a warning» - a possible solution could be to create an intermediate variable with the result of the function call, and then cast this variable to double.

As an alternative solution, this thread suggests to simply turn off warnings in the way described here.

Regards,
Alessia

0 Kudos
Message 2 of 5
(2,061 Views)

Hi Alessia,

thank you for your reply.

About the first point I'm going to turn off the warnings, because I was already using the Alt Code.

For the second point I've already modified my code (in the way you are suggesting me) immediately after getting the warning because I really hate collecting any type of warnings while compiling.

It has been very kind of you, I do really appreciate.

 

Sergio

 

0 Kudos
Message 3 of 5
(2,054 Views)

Alessia, entering the character with Alt+253 (or Alt+0178) by keyboard has the identical effect of entering the character with any other means (e.g. pasting from Character Map application).
So your suggestion sounds somewhat funny to me.  
One simple and working way to have a character literal in a string with code > 127 is by using an escape sequence and the hexadecimal notation. In our case, Sergio should enter "\xB2" and the compiler will no more complain for illegal encoding.
That code will be rendered, when printed, in the current device character set encoding (most likely 8 bit Unicode).

About the other warning, it's a legit warning being a cast applied to the function return value, and the solution proposed by Alessia is correct. 
You can found a slightly more elaborate answer on this warning at this link

Ciao

 

 

 

Carlo A.
Megaris




Message 4 of 5
(2,014 Views)

Hi Carlo,

 

I was supposing that some escape sequence might work but I didn't try, so thank you!

The other warning is legit of course, my question was about the compiler behavior, because I knew that I was recasting something "recastable" being aware about the loss of accuracy and it was acceptable to my purposes.

Again, thank you all.

Ciao

Sergio

 

0 Kudos
Message 5 of 5
(2,013 Views)