pragma warning push[.n] / pop [from msdn]
Push and Pop
The warning pragma also supports the following syntax.
#pragma warning( push [ ,n ] )
#pragma warning( pop )
Where n represents a warning level (1 through 4).
The pragma warning( push ) stores the current warning state for every warning. The pragma warning( push, n) stores the current state for every warning and sets the global warning level to n.
The pragma warning( pop ) pops the last warning state pushed onto the stack. Any changes that you made to the warning state between push and pop are undone. Consider this example:
#pragma warning( push ) #pragma warning( disable : 4705 ) #pragma warning( disable : 4706 ) #pragma warning( disable : 4707 ) // Some code #pragma warning( pop )
At the end of this code, pop restores the state of every warning (includes 4705, 4706, and 4707) to what it was at the start of the code.
When you write header files, you can use push and pop to guarantee that warning-state changes made by a user do not prevent the headers from compiling correctly. Use push at the start of the header and pop at the end. For example, if you have a header that does not compile cleanly at warning level 4, the following code would change the warning level to 3 and then restore the original warning level at the end of the header.
#pragma warning( push, 3 ) // Declarations/definitions #pragma warning( pop )
即保存及恢复当前warning们的状态
Ref: http://msdn.microsoft.com/en-us/library/2c8f766e.aspx