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.
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.
Use a #pragma warning (C#) or Disable (Visual Basic) directive to suppress the warning for only a specific line of code.
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.
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.
Try to use precompiled header and put warnings disable code there. It worked for me with warning C4005.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With