MSVC - stop warnings in headers

后端 未结 3 1497
谎友^
谎友^ 2021-01-12 10:42

I\'m using MSVC with a CMaked project. As a result, I\'ve enabled many of the flags on MSVC which were enabled for gcc and clang. However, the /Wall warning level is giving

3条回答
  •  天涯浪人
    2021-01-12 11:23

    /Wall is very pedantic. /W4 is probably all you really need. To answer your question, you can disable specific warnings around your headers with:

     #pragma warning(disable:xxxx)
     #include 
     #pragma warning(default:xxxx)
    

    Or change the warning level with:

     #pragma warning(push,3)
     #include 
     #pragma warning(pop)
    

    See the MSDN documentation: http://msdn.microsoft.com/en-us/library/2c8f766e.aspx

提交回复
热议问题