/w, /W0, /W1, /W2, /W3, /W4, /w1, /w2, /w3, /w4, /Wall, /wd, /we, /wo, /Wv, /WX (Warning Level)
For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Specifies how the compiler generates warnings for a given compilation.
/w /W0 /W1 /W2 /W3 /W4 /Wall /Wv:<version> /WX /w1<warning> /w2<warning> /w3<warning> /w4<warning> /wd<warning> /we<warning> /wo<warning>
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:
|/w||Disables all compiler warnings.|
|Specifies the level of warnings to be generated by the compiler. Valid warning levels range from 0 to 4:|
- /W0 disables all warnings.
- /W1 displays level 1 (severe) warnings. /W1 is the default setting.
- /W2 displays level 1 and level 2 (significant) warnings.
- /W3 displays level 1, level 2 and level 3 (production quality) warnings.
- /W4 displays level 1, level 2, and level 3 warnings, and all level 4 (informational) warnings that are not turned off by default. We recommend that you use this option only to provide lint-like warnings. However, for a new project, it may be best to use /W4 in all compilations; this will ensure the fewest possible hard-to-find code defects.
|/Wall||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.|
|/Wv:version||Suppress new warnings that were not generated by the specified version of the compiler. If you have code that compiled without warnings when using an older version of the compiler, you can use this option to suppress new warnings in code during migration to a new compiler. We recommend you only use this option temporarily to satisfy clean build requirements, while you update your code to remove the new warnings. The version parameter 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. When the minor or build version numbers are omitted, new warnings are suppressed only in releases of the compiler that have a higher major version number, or if present, minor version number. For example, use |
|/WX||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 nnnn. 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.|
|/wdnnnn||Disables the compiler warning that is specified by nnnn.|
|/wennnn||Treats the compiler warning that is specified by nnnn as an error.|
|/wonnnn||Reports the compiler warning that is specified by nnnn only once.|
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.
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.