C++ _iterator_debug_level 值“0”与值“2”不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4080668/
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
_iterator_debug_level value '0' doesn't match value '2'
提问by tweetypi
I've just moved over a Visual Studio (C++) solution over to another computer, setup all the directories and settings as far as I can see, and did a clean/rebuild on the solution. I get the error above on a bunch of .obj's on compile, not sure what to do about it.
我刚刚将 Visual Studio (C++) 解决方案转移到另一台计算机上,就我所见设置了所有目录和设置,并对解决方案进行了清理/重建。我在编译时收到一堆 .obj 的错误,不知道该怎么办。
采纳答案by Michael Goldshteyn
It seems that you are mixing object files built with different settings. Try to do a full clean rebuild and check all project file settings to make sure that the _ITERATOR_DEBUG_LEVEL macro is the same (e.g., you are not mixing debug and release built objects).
您似乎正在混合使用不同设置构建的目标文件。尝试进行完全干净的重建并检查所有项目文件设置以确保 _ITERATOR_DEBUG_LEVEL 宏相同(例如,您没有混合调试和发布构建对象)。
回答by Andreas Spindler
Mixing binaries (object files) is one reason; another (which I encountered) is the false definition of the _DEBUG
macro in the release build. _DEBUG
is not a standard macro, but used by Microsoft.
混合二进制文件(目标文件)是原因之一;另一个(我遇到的)是_DEBUG
发布版本中宏的错误定义。_DEBUG
不是标准的宏,而是微软使用的。
After editing the .vcxproj-file in Emacs I mistyped _DEBUG
instead of NDEBUG
for the release, and encountered precisely the same build error.
在 Emacs 中编辑.vcxproj文件后,我输入错误_DEBUG
而不是NDEBUG
发布,并遇到完全相同的构建错误。
回答by Ganesh Kamath - 'Code Frenzy'
In some cases, mixing the options in
在某些情况下,混合选项
Properties>Configuration Properties>C/C++>Code Generation>Runtime Library
属性>配置属性>C/C++>代码生成>运行时库
Between included Library(ies)and currently working projectcan cause this problem.
在包含的库和当前工作的项目之间可能会导致此问题。
Depending on usage set it as /MD
or /MT
or /MDd
or /MTd
uniformly across all projects.
根据使用情况,在所有项目中将其设置为/MD
or/MT
或/MDd
or /MTd
。
回答by John Duke
I have been trying to solve this issue for five days. The Point Cloud Library (PCL) code builds successfully in debug mode but fails in release mode.
我已经尝试解决这个问题五天了。点云库 (PCL) 代码在调试模式下成功构建,但在发布模式下失败。
I have reconfigured my library several times but it didn't help. I found the problem was that the release version was inheriting _DEBUG so I unchecked it under project properties >> Preprocessor >> Processor Definitions and it was solved.
我已经多次重新配置我的图书馆,但没有帮助。我发现问题是发布版本继承了_DEBUG,所以我在项目属性>>预处理器>>处理器定义下取消选中它并解决了。
回答by Michael Haephrati
I found out (oddly) that _CRT_NON_CONFORMING_SWPRINTFS causes it. When I remove it, I don't get "_iterator_debug_level value '0' doesn't match value '2'" but instead the following warning:
我发现(奇怪)是 _CRT_NON_CONFORMING_SWPRINTFS 导致的。当我删除它时,我没有收到“_iterator_debug_level value '0' does not match value '2'”而是以下警告:
Error 6 error C4996: '_swprintf': swprintf has been changed to conform with the ISO C standard, adding an extra character count parameter. To use traditional Microsoft swprintf, set _CRT_NON_CONFORMING_SWPRINTFS.
错误 6 错误 C4996:'_swprintf':swprintf 已更改为符合 ISO C 标准,添加了额外的字符计数参数。要使用传统的 Microsoft swprintf,请设置 _CRT_NON_CONFORMING_SWPRINTFS。