/w, /Wn, /WX, /Wall, /wln, /wdn, /wen, /won (Warning Level)
Specifies 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 level of warning to be generated by the compiler. Valid warning levels for n range from 0 to 4:
|
/Wall |
Displays all /W4 warnings and any other warnings that are not included in /W4—for example, warnings that are off 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, /w14326 causes C4326 to be generated as a level 1 warning. |
/wdn |
Disables the compiler warning that is specified in n. For example, /wd4326 disables compiler warning C4326. |
/wen |
Treats as an error the compiler warning that is specified in n. For example, /we4326 flags warning number C4326 as an error. |
/won |
Reports the error only once for the compiler warning that is specified in n. For example, /wo4326 causes warning C4326 to be reported only once. |
If you create a precompiled header (/Yc (Create Precompiled Header File)) by using one of the /w options, any use of the precompiled header (/Yu (Use Precompiled Header File)) causes those same /w options to be in effect again. You can override the /w setting in the precompiled header by using another /w option on 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 that is reported at compile time.
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.
Select C/C++.
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.