Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable C++ warning at project level?

I know you can use a #pragma to disable a warning in a specific file, but I want to "turn off" a certain warning for a whole VC++ 2008 project.

I found an option Configuration Properties->C/C++->Advanced->Disable Specific Warnings but when I entered the numeric warning code and re-compiled the .cpp file in question, the warning was still generated.

like image 471
Mr. Boy Avatar asked Nov 11 '11 12:11

Mr. Boy


People also ask

How do I turn off GCC warnings?

To answer your question about disabling specific warnings in GCC, you can enable specific warnings in GCC with -Wxxxx and disable them with -Wno-xxxx. From the GCC Warning Options: You can request many specific warnings with options beginning -W , for example -Wimplicit to request warnings on implicit declarations.

How do I ignore warnings in C#?

Use a #pragma warning (C#) or Disable (Visual Basic) directive to suppress the warning for only a specific line of code.

How do I stop warnings in CPP?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.


2 Answers

If your project includes other projects or uses objects from another project, make sure you add the warning disable on the project where the warning occurs. This should always work.

like image 133
roboto1986 Avatar answered Sep 24 '22 08:09

roboto1986


Try to use precompiled header and put warnings disable code there. It worked for me with warning C4005.

like image 41
Loryan55 Avatar answered Sep 24 '22 08:09

Loryan55