This option controls the number of warning messages produced by the compiler. Warnings indicate potential problems, rather than actual coding errors, with statements that might not compile as you intend.
/W{0 | 1 | 2 | 3 | 4 | X | all}
/w
A space between /W and 0, 1, 2, 3, 4, or X is optional. Compiler warning messages are any messages beginning with C4. The /W options affect only source files named on the command line; they do not apply to object files.
W1 warnings are the most serious, and W4 warnings are the least serious. The following table describes the warning-level options.
Warning Level | Description |
---|---|
/w | Turns off all warning messages. Use this option when you compile programs that deliberately include questionable statements.
The /w option applies to the remainder of the command line, or applies until the next occurrence of a /w option on the command line. /W and /W0 are the same as /w. |
/W1 | Default. Displays severe warning messages. |
/W2 | Displays an intermediate level of warning messages. Level 2 includes warnings such as the following:
|
/W3 | Displays a less severe level of warning messages, including warnings about function calls that precede their function prototypes in the source code. |
/W4 | Displays the least severe level of warning messages, including warnings about the use constructs and extended keywords that are not ANSI standard. |
/WX | Treats all warnings as errors. If there are any warning messages, the compiler generates an error message, and continues compilation. |
/Wall | Enables all warnings, including warnings that are disabled by default. |
The following code example shows how to enable all possible warning messages for source files Crunch.c and Print.c. Microsoft C/C++ provides a pragma to control warning messages.
CL /W4 CRUNCH.C PRINT.C
See Also
Send Feedback on this topic to the authors