Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual C#
C# Reference
C# Compiler Options
 /warnaserror (Treat Warnings as Err...
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
C# Language Reference
/warnaserror (Treat Warnings as Errors) (C# Compiler Options)

Updated: November 2007

The /warnaserror+ option treats all warnings as errors

/warnaserror[<U>+</U> | -][:warning-list]

Any messages that would ordinarily be reported as warnings are instead reported as errors, and the build process is halted (no output files are built).

By default, /warnaserror- is in effect, which causes warnings to not prevent the generation of an output file. /warnaserror, which is the same as /warnaserror+, causes warnings to be treated as errors.

Optionally, if you want only a few specific warnings to be treated as errors, you may specify a comma-separated list of warning numbers to treat as errors.

Use /warn to specify the level of warnings that you want the compiler to display. Use /nowarn to disable certain warnings.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Properties page.

  2. Click the Build property page.

  3. Modify the Treat Warnings As Errors property.

    To set this compiler option programmatically, see TreatWarningsAsErrors.

Compile in.cs and have the compiler display no warnings:

csc /warnaserror in.cs
csc /warnaserror:642,649,652 in.cs
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker