/W, /w (Warning Level)
| Overview | How Do I | Compiler Options
These options control the number of warning messages produced by the compiler. They affect only source files, not object (.OBJ) files.
Command Line | Project Settings | Description |
/W0 or /w | None | Turns off all warning messages. |
/W1 | Level 1 | Displays severe warning messages. This is the default. |
/W2 | Level 2 | Displays a less-severe level of warning message than /W1. |
/W3 | Level 3 | Displays less-severe warnings than /W2, such as warnings about function calls that precede their function prototypes. /W3 is the most sensitive warning level recommended for production pruposes. |
/W4 | Level 4 | Displays informational warnings which in most cases can be safely ignored. /W4 should be used occasionally to provide “lint” level warnings and is not recommended as your usual warning level setting. |
/WX | Warnings As Errors | Treats all warnings as errors. If there are any warning messages, an error message is emitted and compilation continues. |
To find this option in the development environment, click Settings on the Project menu. Then click the C/C++ tab, and click General in the Category box.
You can also use #pragma warning() to control the level of warning reported at compile time.
On the command line, a space between /W and 0, 1, 2, 3, 4, or X is optional.
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.