1. # pragma warning is only valid for the current file (for. H, it is also valid for CPP containing it), rather than for all files of the entire project. When the file compilation is complete, the setting will become useless.
2. # pragma warning (push)
Store the current Alert settings.
# Pragma warning (push, n)
Store the current Alert settings and set the alert level to n. N is a natural number from 1 to 4.
3. # pragma warning (POP)
Restores the alert settings that were previously pushed into the stack. Any alert settings made between push and pop fail.
4. # pragma warning (Disable: N)
Set an alarm to invalid
5. # pragma warning (default: N)
Set alarm to default
6. Some warnings, such as c4309, take effect from top to bottom. That is, the # pragma warning in the file is traversed from top to bottom, and takes effect in sequence.
For example:
Void func ()
{
# Pragma warning (Disable: 4189)
Char S;
S = 128;
# Pragma warning (default: 4189)
Char C;
C = 128;
}
Then S = 128 will not generate c4309 alarm, while c4309 will generate alarm.
7. Some warnings, for example, c4189, are based on the # pragma warning setting that appears at the end of the function. The other settings for this alarm are invalid.
For example:
Void func ()
{
# Pragma warning (Disable: 4189)
Int x = 1;
# Pragma warning (default: 4189)
}
Then c4189 still appears, because the default command is the last of the function. In other functions in this file, if no resetting is performed, c4189 is also subject to # pragma warning (default: 4189. If you reset it, the last # pragma warning in the function prevails.
8. Some warnings (which msdn considers to be a warning greater than or equal to c4700) take effect only after the function is completed.
For example:
# Pragma warning (Disable: 4700)
Void func ()
{
Int X;
Int y = X;
# Pragma warning (default: 4700)
Int z = X;
}
Y = X and Z = x do not generate c4700 alarms. # Pragma warning (default: 4700) takes effect only in another function after the function is completed.