Change alert level for third-party leaders

I like to compile from level 4 in Visual Studio and treat all warnings as errors. The problem is that Ogre3D does not compile with warning level 3 (neither the FBX SDK nor the OIS, which I also use), and this creates a problem, because now I have a ton of warnings from the Ogre3D libraries, which are now treated as errors. So far I am going to level 3, but it really bothers me. Is there a way to turn off warnings for certain third-party libraries that I have no control over?

+6
c ++ visual-studio-2008 warnings
source share
3 answers

You did not specify exactly how you compile, but here are a few options:

1 - Inside Visual Studio, you can set a warning level for individual source files using the properties for each source file

2 - You can also dynamically change the warning level in a file using

#pragma warning(push, 3) // Some code, perhaps #includes #pragma warning(pop) 

which sets the warning level to 3 between two pragmas.

+7
source share

It may happen that if you turn off the most famous MSVC stupidities, the problem will at least become manageable.

My stupid suppression title is available on my blog ; just compile the code using <windows.h> at the warning level with MSVC without warning.

In addition, in extreme cases you can use the "compiler-firewall", which means full direct use of a third-party library in the implementation file or a set of such files. You can then compile these files with a low warning level. But I donโ€™t think it is worth it.

Cheers and hth.,

+3
source share

You can wrap third-party .h files in your own file and turn off locally warning warnings there, since you can not turn off all warnings, but only specific ones.

 // include_file_wrapper.h #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuninitialized" #include "file.h" #pragma GCC diagnostic pop 

For gcc, here's how to do it

http://gcc.gnu.org/onlinedocs/gcc/Pragmas.html

http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas

+2
source share

All Articles