Search code examples
c++visual-studio-2013warningscompiler-warningssuppress-warnings

VS2013: How to disable warnings for included header files outside of the project


In my project I include a header file provided by an external library. With /W3 everything compiles without warnings. However, I want my project to compile cleanly with /W4. That's no problem for my code, but the external header spits out a ton of warnings. I know that I can do something like this:

#pragma warning( push )
#pragma warning( disable: #### )
// include here
#pragma warning( pop )

However there is a long list of warnings to disable. Is there a way that I can set the warning level back to /W3 when including this header while still compiling the rest of my code with /W4?

Thanks!


Solution

  • #pragma warning(push, 3)
    // include here
    #pragma warning(pop)
    

    See the documentation for details.