I generally like to compile against warning level 4 in Visual Studio and treat all warnings as errors. The problem is, Ogre3D is not compiled with warning level 3 (neither is FBX SDK or OIS, which I am also using), and that poses a problem because now I have a ton of warnings from Ogre3D libraries that are now treated as errors. So far I have been compiling at level 3, but that makes me very uneasy. Is there any way to disable warnings for specific 3rd party libraries over which I have no control?
3 Answers
You don't say exactly how you are compiling, but here are some options:
1 - Inside Visual Studio, you can set the warning level for individual source files via the Properties for each source file
2 - You can also change the the warning level dynamically within a file using
#pragma warning(push, 3)
// Some code, perhaps #includes
#pragma warning(pop)
which sets the warning level to 3 between the two pragmas.

- 19,396
- 12
- 64
- 54
It may be that if you disable the most well-known MSVC sillywarnings, the problem will at least become managable.
My sillywarnings suppression header is available at my blog; it's enough to compile code using <windows.h>
at warning level 4 with MSVC, with no warnings.
Other than that, you can go to the extreme measure of employing a "compiler firewall", which means putting all direct usage of the 3rd party library within an implementation file or set of such files. Then you can compile those files at low warning level. But I don't think it's worth it.
Cheers & hth.,

- 142,714
- 15
- 209
- 331
-
@bobpaul: as far as I can see your area of expertise is Python, not C++. – Cheers and hth. - Alf Mar 01 '11 at 06:37
-
Commercially I do primarily C (embedded) then C++ (product tester). Python is sparetime language of interest. I don't see how this is relevant. – bobpaul Mar 01 '11 at 22:50
-
@bobpaul: well, only a very authoritative source can make a completely unspecified touchy-feely vague negative assessment and have it taken seriously. you're not an authoritative source at all. and i just informed you of that: that i'm not taking seriously, but more like a troll. – Cheers and hth. - Alf Mar 02 '11 at 06:07
You can wrap the 3rd party .h files into your own file and in there disable locally the offending warnings as you might not want to disable 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 is how this can be done
http://gcc.gnu.org/onlinedocs/gcc/Pragmas.html
http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas

- 3,324
- 2
- 27
- 31