Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning as error - How to get rid of these

I cannot figure out how to get rid of errors that basically should not be halting my compile in Visual Studio 2010 and should not be show stoppers, or at least I will fix them later, but I don't want the compile to just error and halt on these kinds of problems.

For example, I'm getting the following error:

Error 1 Warning as Error: XML comment on 'ScrewTurn.Wiki.SearchEngine.Relevance.Finalize(float)' has a paramref tag for 'IsFinalized', but there is no parameter by that name C:\www\Wiki\Screwturn3_0_2_509\SearchEngine\Relevance.cs 60 70 SearchEngine

for this code:

  /// <summary>   /// Normalizes the relevance after finalization.   /// </summary>   /// <param name="factor">The normalization factor.</param>   /// <exception cref="InvalidOperationException">If <paramref name="IsFinalized"/> is <c>false</c> (<see cref="M:Finalize"/> was not called).</exception>   public void NormalizeAfterFinalization(float factor) {       if (factor < 0)           throw new ArgumentOutOfRangeException("factor", "Factor must be greater than or equal to zero");        if (!isFinalized)           throw new InvalidOperationException("Normalization can be performed only after finalization");       value = value * factor;   } 

I looked in menu Tools -> Options, and I don't see where I can tweak the compiler and tell it not to worry about comment or XHTML based errors.

like image 564
PositiveGuy Avatar asked Mar 26 '10 02:03

PositiveGuy


People also ask

How do I turn off error warning?

You can make all warnings being treated as such using -Wno-error. You can make specific warnings being treated as such by using -Wno-error=<warning name> where <warning name> is the name of the warning you don't want treated as an error. If you want to entirely disable all warnings, use -w (not recommended).

Should I treat warnings as errors?

Yes, even once in a while you will encounter the occasional warning you'd be better off leaving as a warning or even disabling completely. Those should be the exception to the rule, though. Here's some practical advise: at the start of a new project, start treating all warnings as errors, by default.

How do I remove compiler warnings?

To turn off the warning for a specific line of code, use the warning pragma, #pragma warning(suppress : 4996) .

How do I ignore warnings in CPP?

To disable a set of warnings for a given piece of code, you have to start with a “push” pre-processor instruction, then with a disabling instruction for each of the warning you want to suppress, and finish with a “pop” pre-processor instruction.


1 Answers

Each project in Visual Studio has a "treat warnings as errors" option. Go through each of your projects and change that setting:

  1. Right-click on your project, select "Properties".
  2. Click "Build".
  3. Switch "Treat warnings as errors" from "All" to "Specific warnings" or "None".

The location of this switch varies, depending on the type of project (class library vs. web application, for example).

like image 161
Michael Petrotta Avatar answered Sep 17 '22 18:09

Michael Petrotta