Warning Level
1. /warn (Specify Warning Level)
/warn:option
where:
- option
- The minimum warning level you want displayed for the build. 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 Displays all level 3 warnings plus informational warnings. This is the default warning level at the command line.
Remarks
The /warn option specifies the warning level for the compiler to display.
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.
Use /warnaserror to treat all warnings as errors. Use /nowarn to disable certain warnings.
/w is the short form of /warn.
To set this compiler option in the Visual Studio development environment
- Open the project's Property Pages dialog box. For details, see Setting Visual C# Project Properties.
- Click the Configuration Properties folder.
- Click the Build property page.
- Modify the Warning Level property.
To set this compiler option programmatically
See WarningLevel Property.
Example
Compile in.cs
and have the compiler only display level 1 warnings:
csc /warn:1 in.cs
2. /w, /Wn, /WX, /Wall, /wln, /wdn, /wen, /won (Warning Level)
//z 2011-09-28 23:43:05@is2120.CSDN 转载请注明出处
最近总用到相关内容,整理了一下
Specify how the compiler generates warnings for a given compilation.
/w /Wn /WX /Wall /wln /wdn /wen /won
The options and related arguments are described in the following table.
Option |
Description |
---|---|
/w |
Disables all compiler warnings. |
/W n |
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 /W4 in all compilations. This will ensure the fewest possible hard-to-find code defects. |
/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. |
/w ln |
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. |
/wd n |
Disables the specified compiler warning where nis the compiler warning number. For example, /wd4326 disables compiler warning C4326. |
/we n |
Treats the specific compiler warning as an error where n is a compiler warning. For example, /we4326 flags warning number C4326 as an error. |
/wo n |
Reports the error only once where n is a compiler warning. For example, /wo4326 will cause warning C4326 to be reported only once. |
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.
To set this compiler option programmatically
3. Change new projects warning level in VS2008 (Express)
I don't know how to do it at the IDE but you cand always edit the new project templates at:
%PROGRAM_FILES%\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\
If you're using the express version there could be a minor variation in the path:
%PROGRAM_FILES%\Microsoft Visual Studio 9.0\Common7\IDE\{Version}\ProjectTemplates\
Where {Version} is the express flavor you are using, VCSExpress, VBExpress, etc.
The templates are zip files, just edit the project changing:
<WarningLevel>3</WarningLevel>
to
<WarningLevel>4</WarningLevel>
@IS2120#CNBLOGS.T2169364049[T1,L65,R1,V259]:备忘
$ € ₤ ₭ ₪ ₩ ₮ ₦ ₱ ฿ ₡ ₫ ﷼ ¥ ﷼ ₫ ₡ ฿ ₱ ₦ ₮ ₩ ₪ ₭ ₤ € $