106

I cannot figure out how to get rid of errors that should not be halting my compilation in Visual Studio 2010, and should not be show-stoppers (I will fix them later). I don't want the compiler to just return an 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, but I don't see where I can tweak the compiler and tell it not to worry about comment or XHTML based errors.

bubbleking
  • 3,329
  • 3
  • 29
  • 49
PositiveGuy
  • 46,620
  • 110
  • 305
  • 471

10 Answers10

173

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).

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
  • do VB projects have the corresponding ability? The only thing I could find was a "Treat all warnings as errors" checkbox on the compile tab. You can add them by directly editing the .vbproj file, but I don't like doing that. – BlackICE Nov 17 '10 at 19:39
  • 1
    Sheesh what a place to hide that. I looked everywhere but under project. – nportelli Nov 15 '11 at 13:44
  • 1
    Does anybody know the new solution for VS2012? – bobble14988 Sep 13 '12 at 10:29
  • 1
    Same solution in VS2012, @bobble14988. – Michael Petrotta Sep 13 '12 at 15:55
  • 6
    @bobble14988 In VS2012 you can find that configuration under Project properties-> C/C++ -> General – Hanan Mar 13 '13 at 10:13
  • The None is disabled. any thoughts? – Jeroen van Langen Oct 03 '17 at 12:21
  • 2
    I wonder why VS 2017 is not honoring the change from All to None. I flipped it, saved everything, cleaned, rebuilt, exited VS, cleaned, rebuilt ad nauseam but warnings are still errors. csproj file is shoing `false` for that setting. Where the hell is this persisted wrong??? I give up before MS devs superior ability to introduce bugs. – ajeh Mar 01 '18 at 16:29
  • Apparently VS 2017 needs a machine reboot after flipping that setting. At least on my machine with Win 10. – ajeh Mar 01 '18 at 16:47
  • Is there a way to see every error code in a list where you get to pick whether each one is treated as error, warning, or information? MonoDevelop has this feature. – Kyle Delaney Mar 19 '18 at 16:45
  • Doesn't work. When I build in Debug all is ok. When I build in Release, all warnings are treated as errors. And they are stupid warnings like "write this with capital letters not lowercase" and such – Thanasis Ioannidis Nov 26 '20 at 14:10
15

For Visual Studio Express 2013 to get rid of these problem you have to do the following.

Right click on your project click Properties. In properties window from left menus select Configuration Properties->C/C++->General

In right side select

Treat Warning As Errors NO

and

SDL Checks NO

Saleh Enam Shohag
  • 1,039
  • 1
  • 12
  • 23
  • 1
    Disabling `SDL Checks` worked for me on Visual Studio 2015. (I had a deprecation warning treated as an error) – Kevin Smyth Oct 11 '17 at 15:15
7

The top answer is outdated for Visual Studio 2015.

English:

Configuration Properties -> C/C++ -> General -> Treat Warning As Errors

German:

Konfigurationseigenschaften -> C/C++ -> Allgemein -> Warnungen als Fehler behandeln

Or use this image as reference, way easier to quickly mentally figure out the location:

enter image description here

kungfooman
  • 4,473
  • 1
  • 44
  • 33
2

VS 2019

Just for people using VS2019, I think other answers are also pointing out same location.

Yoon5oo
  • 496
  • 5
  • 11
1

You can control the behavior in a headerfile or C-file:

#pragma warning(error:4003) //not enough actual parameters for macro

yet tested with Visual studio 2015. I have a common headerfile 'compl_adaption.h' for such things, included in all files, to set this behavior for all my projects compiled on visual studio.

1

I was facing this issue in VS2019 and when I would change it at the Projects Properties UI it would magically return (probably set as default at a higher level)

enter image description here

When using the SDK style CSProj files:

<Project Sdk="Microsoft.NET.Sdk">

adding this PropertyGroup solved the issue:

  <PropertyGroup>
    <NoWarn>;NU1605</NoWarn>
  </PropertyGroup>
John Maloney
  • 1,106
  • 3
  • 15
  • 26
0

To treat all compiler warnings as compilation errors

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.
  2. Click the Compile tab. (or Build Tab may be there)
  3. Select the Treat all warnings as errors check box. (or select the build setting and change the “treat warnings as errors” settings to true.)

and if you want to get rid of it

To disable all compiler warnings

  1. With a project selected in Solution Explorer, on the Project menu click Properties.
  2. Click the Compile tab. (or Build Tab may be there)
  3. Select the Disable all warnings check box. (or select the build setting and change the “treat warnings as errors” settings to false.)
phuclv
  • 37,963
  • 15
  • 156
  • 475
0

In the Properties,

Go to Configuration Properties. In that go to C/C++ (or something like that). ,Then click General ,In that remove the check in the "Treat Warning As Errors" Check Box

Paroda
  • 1
0

View -> Error list -> Right click on specific Error/Warning.

You can change Severity as You want.

Anton Semenov
  • 411
  • 5
  • 11
0

To fix this issue with VS 2019, I did the following:

  • Right clicked project
  • Clicked "Properties"
  • Clicked "C++"
  • On the right side, set table value "Treat Warnings As Errors" to "No"
  • Set the configuration (topleft value) to "Debug" and "x64". This may be different for your project depending on what you are doing
  • Closed "Properties" menu
  • Set configuration of project as "Debug" and "x64"
  • Restarted Visual Studio (closed and re-opened it)

Worked like a charm.

BITWISE
  • 115
  • 1
  • 8