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

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

    The first approach allows you change the specific warning setting in a local scope. It first stores all the current warning state by push into stack, apply your warning modifications, then restore (pop) to last warning state.

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

提交回复
热议问题