Is using #pragma warning push/pop the right way to temporarily alter warning level?

后端 未结 7 1565
别跟我提以往
别跟我提以往 2020-11-28 04:00

Once in a while it\'s difficult to write C++ code that wouldn\'t emit warnings at all. Having warnings enabled is however a good idea. So it is often necessary to disable wa

7条回答
  •  独厮守ぢ
    2020-11-28 04:16

    The correct approach (although a bit ugly)

    #ifdef _MSC_VER
     #pragma warning( push )
     #pragma warning( once: ThatWarning )
    #endif
     //code with ThatWarning here
    #ifdef _MSC_VER
     #pragma warning( pop )
    #endif
    

提交回复
热议问题