如何决定_ITERATOR_DEBUG_LEVEL? [英] How to decide _ITERATOR_DEBUG_LEVEL?

查看:44
本文介绍了如何决定_ITERATOR_DEBUG_LEVEL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!



我已经建立了Lib。在发布模式下。之后我在调试模式下的项目中使用它并且我收到错误:



错误LNK2038:检测到'_ITERATOR_DEBUG_LEVEL'不匹配:值'0'没有' t匹配.obj中的值'2'

错误LNK2038:检测到'RuntimeLibrary'不匹配:值'MD_DynamicRelease'与'

我无法更改Lib选项的问题。我必须在Release下构建它。



是否可以欺骗visual studio并在Debug模式下使用release lib?

Hello!

I have build Lib. in Release mode. After that I use it in my project under Debug mode and I'm getting error:

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in .obj
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in

The problem that I can't change options of Lib. and I have to build it under Release.

Is it possible to cheat visual studio and use release Lib in project with Debug mode?

推荐答案

只能在一小部分情况下混合调试和发布链接:

- 如果你使用普通旧数据/ POD类型跨越DLL边界方法参数。

- 如果你有任何只包含POD数据的类。

- 如果只传递const项并接收POD返回值。

- 如果你处理跨越边界的任何类数据,那么边界的两边必须以完全相同的方式看到类(例如,在发布版本中没有#ifdef out,对齐相同,......)

- 如果跨DLL边界调用具有类数据的API,则必须在一个地方或另一个地方完成所有内存管理。如果在DLL中创建了一个对象,那么它也必须在那里删除。

- 我还没有发现其他几种可能性......



请注意以下示例:

- CString和std :: string在调试/发布之间或编译器的不同版本之间不一定是安全的。可悲但是真的,你需要在OOPS代码中使用char *和const char *。

- 任何Microsoft结构或类在调试/发布和不同构建之间都应该没问题。确保在任何结构中正确设置了大小字段。
You can mix debug and release linkage only under a short list of circumstances:
- If you cross the DLL boundary using "plain old data"/POD types in all method parameters.
- If you have any classes that contain only POD data.
- If you pass only const items and receive POD return values.
- If you deal with any class data across the boundary, then both sides of the boundary must see the class exactly the same way (eg. nothing #ifdef'd out in release build, alignment the same, ...)
- If you call an API across the DLL boundary that has class data, then all memory management must be done in one place or the other. If an object is created in the DLL, it must be deleted there as well.
- Several other possibilities that I haven't identified off the top of my head...

Note the following examples:
- CString and std::string are not (necessarily) safe between debug/release or between different builds of the compiler. Sad but true, you need to use "char*" and "const char*" in OOPS code.
- Any Microsoft struct or class should be fine between debug/release and different builds. Make sure that you correctly set the size field in any structs.


这篇关于如何决定_ITERATOR_DEBUG_LEVEL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆