visual-studio 警告错误 - 如何消除这些
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2520853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Warning as error - How to rid these
提问by PositiveGuy
I cannot figure out how to get rid of errors that basically should not be halting my compile in Visual Studio 2010and 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.
我不知道如何消除错误,这些错误基本上不应该停止我在Visual Studio 2010 中的编译,也不应该显示停止器,或者至少我稍后会修复它们,但我不希望编译只是错误和停止这些类型的问题。
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
错误 1 警告为错误:“ScrewTurn.Wiki.SearchEngine.Relevance.Finalize(float)”上的 XML 注释具有“IsFinalized”的 paramref 标记,但没有该名称的参数 C:\www\Wiki\Screwturn3_0_2_509\SearchEngine \Relevance.cs 60 70 搜索引擎
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.
我查看了菜单Tools-> Options,我没有看到我可以在哪里调整编译器并告诉它不要担心基于注释或 XHTML 的错误。
回答by Michael Petrotta
Each project in Visual Studio has a "treat warnings as errors" option. Go through each of your projects and change that setting:
Visual Studio 中的每个项目都有一个“将警告视为错误”选项。浏览您的每个项目并更改该设置:
- 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).
此开关的位置会有所不同,具体取决于项目类型(例如,类库与 Web 应用程序)。
回答by Saleh Enam Shohag
For Visual Studio Express 2013 to get rid of these problem you have to do the following.
为了让 Visual Studio Express 2013 摆脱这些问题,您必须执行以下操作。
Right click on your project click Properties. In properties window from left menus select Configuration Properties->C/C++->General
右键单击您的项目单击属性。在左侧菜单的属性窗口中选择 配置属性->C/C++->常规
In right side select
在右侧选择
Treat Warning As Errors NO
将警告视为错误 否
and
和
SDL Checks NO
SDL 检查否
回答by lama12345
The top answer is outdated for Visual Studio 2015.
最佳答案已过时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:
或者使用此图像作为参考,更容易快速在脑海中找出位置:
回答by Alfa Thakkar
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.)
- 在解决方案资源管理器中选择一个项目后,在“项目”菜单上,单击“属性”。
- 单击编译选项卡。(或构建选项卡可能在那里)
- 选中将所有警告视为错误复选框。(或选择构建设置并将“将警告视为错误”设置更改为 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.)
- 在解决方案资源管理器中选择一个项目后,在“项目”菜单上单击“属性”。
- 单击编译选项卡。(或构建选项卡可能在那里)
- 选中禁用所有警告复选框。(或选择构建设置并将“将警告视为错误”设置更改为 false。)
回答by Hartmut Schorrig
You can control the behavior in a headerfile or C-file:
您可以控制头文件或 C 文件中的行为:
#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.
尚未使用 Visual Studio 2015 进行测试。我有一个用于此类内容的通用头文件“compl_adaption.h”,包含在所有文件中,用于为我在 Visual Studio 上编译的所有项目设置此行为。
回答by Paroda
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
转到配置属性。在那去 C/C++ (或类似的东西)。,然后单击 General ,在该复选框中取消选中“Treat Warning As Errors”复选框


