C++ _ITERATOR_DEBUG_LEVEL = 1 是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4130044/
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
What does _ITERATOR_DEBUG_LEVEL = 1 mean?
提问by Skrymsli
In VS2010, C++ project I get this error when linking in x64/Release:
在 VS2010 中,C++ 项目在 x64/Release 中链接时出现此错误:
error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '1'
错误 LNK2038:检测到“_ITERATOR_DEBUG_LEVEL”不匹配:值“0”与值“1”不匹配
All other configuration/platform combinations link just fine. So a static library is built with _ITERATOR_DEBUG_LEVEL set to 0 and the .dll that depends on it somehow has _ITERATOR_DEBUG_LEVEL set to 1. I'm trying to figure out what that means so I can figure out how to turn it off!
所有其他配置/平台组合链接都很好。因此,静态库构建时 _ITERATOR_DEBUG_LEVEL 设置为 0,而依赖于它的 .dll 以某种方式将 _ITERATOR_DEBUG_LEVEL 设置为 1。我试图弄清楚这意味着什么,以便我可以弄清楚如何将其关闭!
The only references to this error that I found while Googling are when _ITERATOR_DEBUG_LEVEL's conflict with values of 0 and 2. That indicates an attempt to link release with debug. But I'm sure that's not the case here.
我在谷歌搜索时发现的对这个错误的唯一引用是 _ITERATOR_DEBUG_LEVEL 与 0 和 2 的值发生冲突。这表明尝试将发布与调试联系起来。但我确信这里的情况并非如此。
回答by Skrymsli
Well, after struggling with this for an hour I figured it out right after I asked the question... for posterity:
好吧,在为此挣扎了一个小时后,我在提出问题后立即想通了……为了后代:
_ITERATOR_DEBUG_LEVEL = 0 (in release mode)
_ITERATOR_DEBUG_LEVEL = 1 (in release mode if _SECURE_SCL is defined)
_ITERATOR_DEBUG_LEVEL = 2 (in debug mode)
Somehow I had _SECURE_SCL defined as a preprocessor definition only in the Release/x64 configuration of my DLL and I had to squint really hard to notice it. Once I removed that definition, the error went away.
不知何故,我仅在我的 DLL 的 Release/x64 配置中将 _SECURE_SCL 定义为预处理器定义,我不得不眯着眼睛很难注意到它。一旦我删除了该定义,错误就消失了。
Edit:I found this nice lecture/tutorial on msdn that (among other things) explains _ITERATOR_DEBUG_LEVEL. Unfortunately, it does require a fairly recent version of Microsoft Silverlight to watch.
编辑:我在 msdn 上发现了这个很好的讲座/教程(除其他外)解释了 _ITERATOR_DEBUG_LEVEL。不幸的是,它需要相当新版本的 Microsoft Silverlight 才能观看。
回答by Paul Skibitzke
For those with immaculate preprocessor definitions, yet still suffering from this error, check the project's runtime library setting.
对于那些具有完美预处理器定义但仍然遭受此错误的人,请检查项目的运行时库设置。
If set to either one of the debug versions, _ITERATOR_DEBUG_LEVEL
will get set to 2.
如果设置为任一调试版本,_ITERATOR_DEBUG_LEVEL
将设置为 2。
回答by Paladine
I ran into this problem on a release build, but I found that my preprocessor was defining _DEBUG when it should have been NDEBUG. Changing to NDEBUG fixed the problem.
我在发布版本中遇到了这个问题,但我发现我的预处理器在定义 _DEBUG 时它应该是 NDEBUG。更改为 NDEBUG 解决了该问题。