visual-studio 如何解决以下 C2220 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/933862/
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
How to resolve the following C2220 error?
提问by Cute
I am getting the following error while building a project. Even though I am setting the property "treat warning as errors" to "NO" I am getting this one:
构建项目时出现以下错误。即使我将属性“将警告视为错误”设置为“否”,我也得到了这个:
error C2220: warning treated as error - no object file is created.
Can any one Help me Resolving This One? Thanks in Advance.
任何人都可以帮我解决这个问题吗?提前致谢。
回答by sean e
The documentation for C2220suggests compiling at a lower warning level. It also shows that the warning treated as error option is implemented as a compiler flag: /WX. So you could search your .vcproj file for that text and manually remove it from the file.
C2220的文档建议以较低的警告级别进行编译。它还表明,被视为错误选项的警告是作为编译器标志实现的:/WX。因此,您可以在 .vcproj 文件中搜索该文本并手动将其从文件中删除。
回答by sparco
I got "error C2220: warning treated as error - no object file is created." in below code.
Once I changed datatypeof total to int, the error was resolved.
我收到“错误 C2220:警告被视为错误 - 未创建目标文件。” 在下面的代码中。
一旦我将total 的数据类型更改为int,错误就解决了。
int colNum=0;
unsigned int total=123;
for (colNum=0;colNum<total;colNum++) {
回答by AKN
#pragma warning(disable : 4146)
Set this at the file level instead of changing the project setting.
在文件级别进行设置,而不是更改项目设置。
回答by Sacx
Probably you forgot to add an header. Just where you get the first warning and see in what header file is defined.
可能您忘记添加标题。就在您收到第一个警告的地方,并查看定义了哪个头文件。
Regards
问候

