-1

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.

rahul sharma
  • 89
  • 1
  • 10
  • Does this answer your question? [What does \_ITERATOR\_DEBUG\_LEVEL = 1 mean?](https://stackoverflow.com/questions/4130044/what-does-iterator-debug-level-1-mean) [How to set _ITERATOR_DEBUG_LEVEL in VS2010?](https://stackoverflow.com/questions/5727815/how-to-set-iterator-debug-level-in-vs2010) [_ITERATOR_DEBUG_LEVEL error in visual studio](https://stackoverflow.com/questions/4738987/iterator-debug-level-error-in-visual-studio/4739353) – 273K Feb 21 '22 at 17:23
  • No, It is different. I just want to know, how can we check ITERATOR_DEBUG_LEVEL value just by using .lib file. – rahul sharma Feb 22 '22 at 05:14

1 Answers1

0

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.

273K
  • 29,503
  • 10
  • 41
  • 64