This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
/Wn, /WX, /Wall, /wnn, /wdn, /wen, /won (Warning Level)
/Wn
/WX
/Wall
/wnn
/wdn
/wen
/won
These options specify how the compiler generates warnings for a given compilation.
- /Wn
- Specifies the highest level of warning generated by the compiler. Valid warning levels for n range from 0 to 4:
- Level 0 disables all warnings.
- Level 1 displays severe warnings.
- Level 2 displays all level 1 warnings and warnings less severe than level 1. Level 2 is the default warning level at the command line.
- Level 3 displays all level 2 warnings and all other warnings recommended for production purposes.
- Level 4 displays all level 3 warnings plus informational warnings, which in most cases can be safely ignored. This option should be used only to provide "lint" level warnings and is not recommended as your usual warning level setting.
- /Wall
- Enables all warnings, including those disabled by default.
- /WX
- Treats all warnings as errors.
- /wnn
- Specifies the level for a particular warning. The first parameter sets the warning level (same as /Wn) and the second parameter is the actual warning number.
For example, /w14326
causes C4326 to be generated as a level 1 warning.
- /wdn
- Disables the specified compiler warning where n is the compiler warning number.
For example, /wd4326
disables compiler warning C4326.
- /wen
- Treats the specific compiler warning as an error.
For example, /we4326
flags warning number C4326 as an error.
- /won
- Reports the error only once where n is the number for the desired compiler warning.
For example, /wo4326
will cause warning C4326 to be reported only once.
If you create a precompiled header (/Yc) with one of the /w options, any use of the precompiled header (/Yu) will cause those same /w options to be in effect again. You can override the /w setting in the precompiled header with another /w option at the command line.
Pragma directives in source code are unaffected by the /w option.
You can also use #pragma warning() to control the level of warning reported at compile time.
The Build Errors documentation describes the warnings, indicates each warning’s level, and indicates potential problems (rather than actual coding errors) with statements that may not compile as you intend.
See Also
Compiler Options | Setting Compiler Options