'How can i know, What is the ITERATOR_DEBUG_LEVEL value of a .lib file?
I am generating some .lib(eg- libcef_dll_wrapper.lib) files and later after some steps using this .lib file in myCustomApp. I am getting below error in Visual Studio debug build only.
LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in customfile.obj
There are many steps between creation of this .lib file and using it in my custom application. Is there any way so that i can check ITERATOR_DEBUG_LEVEL value just after creation of this .lib file? Please help.
Solution 1:[1]
I am afraid, how this information is stored in a .lib archive file is not well documented.
A compiler stores the value with the name "_ITERATOR_DEBUG_LEVEL" got by _STRINGIZE(_ITERATOR_DEBUG_LEVEL).
#define _STRINGIZEX(x) #x
#define _STRINGIZE(x) _STRINGIZEX(x)
You may parse a .lib archive and .obj files in an archive and look for "_ITERATOR_DEBUG_LEVEL" value.
The code bellow from yvals.h detects the value mismatch while linkage, see #pragma detect_mismatch
#pragma detect_mismatch("_ITERATOR_DEBUG_LEVEL", _STRINGIZE(_ITERATOR_DEBUG_LEVEL))
When you link the project, the linker throws a LNK2038 error if the project contains two objects that have the same name but each has a different value. Use this pragma to prevent inconsistent object files from linking.
Both name and value are string literals and obey the rules for string literals with respect to escape characters and concatenation. They are case-sensitive and cannot contain a comma, equal sign, quotation marks, or the null character.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | 273K |
