/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)
Specifies how the compiler generates warnings for a given compilation.
The warning options specify which compiler warnings to display and the warning behavior for the entire compilation.
The warning options and related arguments are described in the following table:
Disables all compiler warnings.
Specifies the level of warnings to be generated by the compiler. Valid warning levels range from 0 to 4:
Displays all warnings displayed by /W4 and all other warnings that /W4 does not include—for example, warnings that are off by default. For more information, see Compiler Warnings That Are Off By Default.
Disable warnings introduced in compiler versions newer than version. You can use this option to determine if there are new warnings in code that compiled without warnings when using an older version of the compiler, and to remove them from your build. The optional parameter version takes the form nn[.mm[.bbbbb]] where nn is the major version number, mm is the optional minor version number, and bbbbb is the optional build number of the compiler. For example, use /Wv17.00.00000 to disable warnings introduced in Visual C++ 2012 and later. By default, /Wv uses the current compiler version number, and no warnings are disabled.
Treats all compiler warnings as errors. For a new project, it may be best to use /WX in all compilations; resolving all warnings ensures the fewest possible hard-to-find code defects.
The linker also has a /WX option. For more information, see /WX (Treat Linker Warnings as Errors).
Sets the warning level for the warning number specified by n. This lets you change the compiler behavior for that warning when a specific warning level is set. You can use these options in combination with other warning options to enforce your own coding standards for warnings, rather than the default ones provided by Visual Studio.
For example, /w34326 causes C4326 to be generated as a level 3 warning instead of level 1. If you compile by using both the /w34326 option and the /W2 option, warning C4326 is not generated.
Disables the compiler warning that is specified by n.
For example, /wd4326 disables compiler warning C4326.
Treats the compiler warning that is specified by n as an error.
For example, /we4326 causes warning number C4326 to be treated as an error by the compiler.
Reports the compiler warning that is specified by n only once.
For example, /wo4326 causes warning C4326 to be reported only once, the first time it is encountered by the compiler.
If you use any of the warning options when you create a precompiled header by using the /Yc option, any use of the precompiled header by using the /Yu option causes those same warning options to be in effect again. You can override the warning options set in the precompiled header by using another warning option on the command line.
You can use a #pragma warning directive to control the level of warning that is reported at compile time in specific source files.
Pragma warning directives in source code are unaffected by the /w option.
The build errors documentation describes the warnings and warning levels, and indicates why certain statements may not compile as you intend.
To set the compiler option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.
On the General property page, modify the Warning Level or Treat Warnings as Errors properties.
On the Advanced property page, modify the Disable Specific Warnings property.
For the remaining options, on the Command Line property page, type the compiler option in the Additional Options box.