Warning as error - How to get rid of these
Visual StudioVisual Studio-2010Visual Studio Problem Overview
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.
Visual Studio Solutions
Solution 1 - Visual Studio
Each project in Visual Studio has a "treat warnings as errors" option. Go through each of your projects and change that setting:
- Right-click on your project, select "Properties".
- Click "Build".
- 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).
Solution 2 - Visual Studio
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
Solution 3 - Visual Studio
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:
Solution 4 - Visual Studio
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.
Solution 5 - Visual Studio
Solution 6 - Visual Studio
To treat all compiler warnings as compilation errors
- With a project selected in Solution Explorer, on the Project menu, click Properties.
- Click the Compile tab. (or Build Tab may be there)
- 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
- With a project selected in Solution Explorer, on the Project menu click Properties.
- Click the Compile tab. (or Build Tab may be there)
- Select the Disable all warnings check box. (or select the build setting and change the “treat warnings as errors” settings to false.)
Solution 7 - Visual Studio
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
Solution 8 - Visual Studio
View -> Error list -> Right click on specific Error/Warning.
You can change Severity as You want.
Solution 9 - Visual Studio
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.
Solution 10 - Visual Studio
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)
When using the SDK style CSProj files:
<Project Sdk="Microsoft.NET.Sdk">
adding this PropertyGroup solved the issue:
<PropertyGroup>
<NoWarn>;NU1605</NoWarn>
</PropertyGroup>