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

后端 未结 7 1529
别跟我提以往
别跟我提以往 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:32

    I have no problems with the first variant. May be the better way is to use the following:

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

    This will let you know that there're still warnings in the code, but the warning messages will not be so annoying. But that is the matter of taste.

    0 讨论(0)
提交回复
热议问题