About #pragma Warning
1. #pragma Warning only valid for the current file (for .h, it is also valid for the CPP containing it), not all files for the entire project. When the file is completed, the setting is lost.
2. #pragma Warning (Push)
Store the current alarm setting.
#pragma Warning (Push, N)
Store the current alarm setting and set the alarm level to n. N is a natural number from 1 to 4.
3. #pragma Warning (POP)
The alarm settings that are pressed into the stack before recovery. Any alarm related settings between a pair of PUSH and POP will be invalid.
4. #pragma Warning (Disable: N)
Report a warning as a failure
5. #pragma Warning (Default: n)
Set alarm as default
6. Some warnings such as C4309 take effect from top to bottom. That is, the #pragma Warning from top to bottom is over, take effect in turn.
E.g:
Void func ()
{
#pragma Warning (Disable: 4189)
Char S;
S = 128;
#pragma Warning (Default: 4189)
Char C;
C = 128;
}
Then s = 128 does not generate a C4309 alarm, and C4309 will have alarm.
7. Some warnings, for example, C4189 is set by the last #pragma Warning setting in the function, and the rest of the alarm is invalid.
E.g:
Void func ()
{
#pragma Warning (Disable: 4189)
INT x = 1;
#pragma Warning (Default: 4189)
}
Then C4189 will still appear because the Default command is the last one of the functions. In other functions in this file, if it is not reset, C4189 is also subject to #pragma Warning (Default: 4189). If reset, it is also the case in accordance with the last #pragma Warning in its function.
8. Some warnings (MSDN considered to be greater than or equal to C4700) is to take effect after the function is completed.
E.g:
#pragma Warning (Disable: 4700)
Void func ()
{
INT X;
INT Y = X;
#pragma Warning (Default: 4700)
INT Z = x;
}
Then y = x and z = x do not produce a C4700 alarm. Only another function after the function is over, # pragma warning (Default: 4700) can take effect.