/w, /Wn, /WX, /Wall, /wln, /wdn, /wen, /won (Warning Level)
Specify how the compiler generates warnings for a given compilation.
/w
/Wn
/WX
/Wall
/wln
/wdn
/wen
/won
Remarks
The options and related arguments are described in the following table.
Option | Description |
---|---|
/w |
Disables all compiler warnings. |
/Wn |
Specifies the highest level of warning generated by the compiler. Valid warning levels for n range from 0 to 4:
For a new project, it may be best to use |
/Wall |
Enables all warnings, including those disabled by default. See Compiler Warnings That Are Off By Default. |
/WX |
Treats all compiler warnings as errors. For a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects. The linker also has a /WX option; see /WX (Treat Linker Warnings as Errors) for more information. |
/wln |
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, |
/wdn |
Disables the specified compiler warning where n is the compiler warning number. For example, |
/wen |
Treats the specific compiler warning as an error where n is a compiler warning. For example, |
/won |
Reports the error only once where n is a compiler warning. For example, |
If you create a precompiled header (/Yc (Create Precompiled Header File)) with one of the /w options, any use of the precompiled header (/Yu (Use Precompiled Header File)) 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 warning to control the level of warning reported at compile time.
The C/C++ Build Errors 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.
To set this 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.
Click the C/C++ folder.
Click the General property page and modify the Warning Level or Treat Warnings as Errors properties.
Click the Advanced property page and modify the Disable Specific Warnings property.
For the remaining options, click the Command Line property page and type the compiler option in the Additional Options box.