/warnaserror (Visual Basic)
Causes the compiler to treat the first occurrence of a warning as an error.
/warnaserror[+ | -][:numberList]
Arguments
Term |
Definition |
+ | - |
Optional. By default, /warnaserror- is in effect; warnings do not prevent the compiler from producing an output file. The /warnaserror option, which is the same as /warnaserror+, causes warnings to be treated as errors. |
numberList |
Optional. Comma-delimited list of the warning ID numbers to which the /warnaserror option applies. If no warning ID is specified, the /warnaserror option applies to all warnings. |
Remarks
The /warnaserror option treats all warnings as errors. Any messages that would ordinarily be reported as warnings are instead reported as errors. The compiler reports subsequent occurrences of the same warning as warnings.
By default, /warnaserror- is in effect, which causes the warnings to be informational only. The /warnaserror option, which is the same as /warnaserror+, causes warnings to be treated as errors.
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.
Note
The /warnaserror option does not control how warnings are displayed. Use the /nowarn option to disable warnings.
To set /warnaserror to treat all warnings as errors in the Visual Studio IDE |
|
To set /warnaserror to treat specific warnings as errors in the Visual Studio IDE |
|
Example
The following code compiles In.vb and directs the compiler to display an error for the first occurrence of every warning it finds.
vbc /warnaserror in.vb
The following code compiles T2.vb and treats only the warning for unused local variables (42024) as an error.
vbc /warnaserror:42024 t2.vb
See Also
Reference
Sample Compilation Command Lines (Visual Basic)
Concepts
Configuring Warnings in Visual Basic