To disable warnings from system headers that you have no control over, simply use this construct:
#pragma warning(push, 0) //Some includes with unfixable warnings #pragma warning(pop)
or more selectively for specific warnings:
#pragma warning( push ) #pragma warning( disable : 4081) #pragma warning( disable : 4706 ) // system header includes #pragma warning( pop )
This answer has been stolen from another thread: ( https://stackoverflow.com/a/167478/ ).
I completely agree with the comments of "edA-qa mort-ora-y". I want to see all warnings in my code, including important things like C4265 (DTOR is not virtual). Although C4265 is at warning level 3, Microsoft thought it turned it off by default, and you need / Wall to get it. See this page for more information about which warnings are hidden:
http://msdn.microsoft.com/en-GB/library/23k5d385(v=vs.80).aspx
To see them and suppress noise from external headers, this page gives excellent advice, and I think that fully answers the original question that started this topic:
http://blogs.msdn.com/b/vcblog/archive/2010/12/14/off-by-default-compiler-warnings-in-visual-c.aspx
Essentially, he advises creating a βglobalβ include file with the appropriate #pragmas to suppress warnings that you are not interested in (maybe C4820 indented), to protect against external headers, as described above, then compile with / Wall. This is part of the job, but worth it. With GCC, this will simply be a matter of using -isystem. Microsoft Development: Pay Attention! VS is a smart product, but sometimes it's just stupid.
woodspiral May 18 '13 at 19:20 2013-05-18 19:20
source share