LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler Warnings: Extended / All - possible to ignore certain warnings?

Solved!
Go to solution

There are some useful compiler warnings I would like to see in the code I am working on (loss of precision and such), but if I crank the Warning level up beyond Common I get tons of warnings from windows header files, such as:

 

  • "winnt.h"(8780,19) warning: cast from function call of type 'LONG64' (aka 'long long') to non-matching type 'PVOID' (aka 'void *') [-Wbad-function-cast]
  • "WinBase.h"(7130,5) warning: 'TpSetCallbackThreadpool' was marked unused but was used [-Wused-but-marked-unused]

I'd be okay with a flag to ignore those two warnings, so I can see things I am more interested in such as:

 

  • "myfile.h"(145,1) warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wconversion]
  • 880, 1 warning: assigning to 'int' from 'unsigned long long' might lose data [-Wtypecheck-convert]
  • 374, 1 warning: function declaration isn't a prototype. [-Wstrict-prototypes]

Is there a way to ignore specific warnings?


We are using 2017.


Thanks!

0 Kudos
Message 1 of 10
(1,727 Views)

The help file has helped a bit ... in the Build Options window, where I can select "Warning level:", there is a "..." browse button. It seems to let me uncheck warnings, which I can match from the -Wxxxx text description.


Ideally, I'd like to ignore just the ones in those files, since some could apply to my code, but this may be a start.

0 Kudos
Message 2 of 10
(1,724 Views)

Hi

 

I use the following commands to avoid those warning. The commands are inserted into my precompiled header file:

 

// Do not report system header warnings
#pragma clang diagnostic push


#pragma clang diagnostic ignored "-Wbad-function-cast" //warning: cast from function call of type A to non-matching type B
#pragma clang diagnostic ignored "-Wtypecheck-convert" //warning: assigning to 'x' from 'y' might lose data
#pragma clang diagnostic ignored "-Wused-but-marked-unused" //warning: 'Function' was marked unused but was used
#pragma clang diagnostic ignored "-Wbad-function-cast" //warning: cast from function call of type A to non-matching type B

 

#include <windows.h>

#include <shlobj.h>

 

#pragma clang diagnostic pop

 

 

Jan

Message 3 of 10
(1,679 Views)
Solution
Accepted by topic author AllenInIowa

You can customize the warnings that are prompted while building the project: goto to Options >> Build options and click on the button highlighted below:

Screenshot 2020-09-24 15.25.45.png

 

This will lead you to the Compiler Warnings screen where you can choose which of them to activate or not:

Screenshot 2020-09-24 15.26.19.png

 

Buuu! The damnation of small screens! I dodn't realized this question was already answered! 😞



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 10
(1,672 Views)

Thanks for these answers. As to setting up Build Options, I did that yesterday then spent hours cleaning up compiler warnings in our code. Then, when I started today, I had to do them all again when I was building the Installer package.

 

I now see they have to be toggled for Release and Build.  Do these save with the project?

 

0 Kudos
Message 5 of 10
(1,664 Views)

I'll try this in the various spots where we are including <windows.h> and see what happens. Thanks!

 

I did not realize LabWindows was using Clang.  The docs I read say it is not an optimizing compiler. Was Cland being used for the 2017 edition?

0 Kudos
Message 6 of 10
(1,660 Views)

I am trying this out, manually wrapped around includes of <windows.h> for testing:

 

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbad-function-cast" //warning: cast from function call of type A to non-matching type B
#pragma clang diagnostic ignored "-Wtypecheck-convert" //warning: assigning to 'x' from 'y' might lose data
#pragma clang diagnostic ignored "-Wused-but-marked-unused" //warning: 'Function' was marked unused but was used
#pragma clang diagnostic ignored "-Wbad-function-cast" //warning: cast from function call of type A to non-matching type B
#include <windows.h>
#pragma clang diagnostic pop

 

But, then I find errors from <stdint.h> and other standard C files that end up including some CVI files.

 

26, 1 In file included from c:\Users\huffm\Perforce\allenhuffman\Development\SST\Host\PrecisePower\BandMapOptionsCallbacks.c:26:

"stdint.h"(17,1) In file included from c:\program files (x86)\national instruments\cvi2017\include\ansi\stdint.h:17:

"cvirte.h"(30,9) warning: calling convention '__stdcall' ignored for this target [-Wignored-attributes]

"cvidef.h"(122,29) note: expanded from macro 'CVIFUNC'

 

WHAC-A-MOLE continues 🙂  I see this -Wignored-attributes was not in your list. Are not not including anything like stdint.h that would require this?

 

Thanks for these replies, folks!

0 Kudos
Message 7 of 10
(1,658 Views)

The Configuration field (first one in Build Options window) can be set to "All configurations" so your choices are valid in all cases. I don't know if they are saved at project level or not.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 10
(1,654 Views)

Thanks, everyone. I am just ignoring them using project options, since I found warnings even when including ANSI C header files like:

 

#include <stdint.h>

 

That ends up including some CVI files that had the issues.

 

0 Kudos
Message 9 of 10
(1,644 Views)

For a simple one-file text program, I was able to silence all the warnings by doing this in my main .c file:

 

//==============================================================================
// Include files
// Do not report system header warnings
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wbad-function-cast"
#pragma clang diagnostic ignored "-Wpadded"
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wused-but-marked-unused"
#include "Windows.h"
#include "asynctmr.h"
#include "CommCtrl.h"

#include <ansi_c.h>
#include <cvirte.h>
#include <userint.h>

#include "User Interface Application.h"
#include "toolbox.h"
#include <stdbool.h>
#pragma clang diagnostic pop

 

I suppose anything I include that is not mine is beyond my control, so getting in to the habit of doing this is what I need to do.

0 Kudos
Message 10 of 10
(1,640 Views)