| title | -warn (C# Compiler Options) | |||||||
|---|---|---|---|---|---|---|---|---|
| ms.date | 07/20/2015 | |||||||
| ms.prod | .net | |||||||
| ms.technology |
|
|||||||
| ms.topic | article | |||||||
| f1_keywords |
|
|||||||
| helpviewer_keywords |
|
|||||||
| ms.assetid | 5f80ff59-4991-4382-9f9a-77da18446e71 | |||||||
| caps.latest.revision | 17 | |||||||
| author | BillWagner | |||||||
| ms.author | wiwagn |
The -warn option specifies the warning level for the compiler to display.
-warn:option option
The warning level you want displayed for the compilation: Lower numbers show only high severity warnings; higher numbers show more warnings. Valid values are 0-4:
| Warning level | Meaning |
|---|---|
| 0 | Turns off emission of all warning messages. |
| 1 | Displays severe warning messages. |
| 2 | Displays level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members. |
| 3 | Displays level 2 warnings plus certain, less-severe warnings, such as warnings about expressions that always evaluate to true or false. |
| 4 (the default) | Displays all level 3 warnings plus informational warnings. |
To get information about an error or warning, you can look up the error code in the Help Index. For other ways to get information about an error or warning, see C# Compiler Errors.
Use -warnaserror to treat all warnings as errors. Use -nowarn to disable certain warnings.
-w is the short form of -warn.
-
Open the project's Properties page.
-
Click the Build property page.
-
Modify the Warning Level property.
For information on how to set this compiler option programmatically, see xref:VSLangProj80.CSharpProjectConfigurationProperties3.WarningLevel%2A.
Compile in.cs and have the compiler only display level 1 warnings:
csc -warn:1 in.cs C# Compiler Options
Managing Project and Solution Properties