error LNK2038: mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘2’ doesn’t match value ‘0’ in xxx.obj

Finally, I think I find a workaround to your linking failure. Here is what under the
hood, please be patient to read through. 🙂

 

First of all to answer your question, MC3 never explicitly sets
_HAS_ITERATOR_DEBUGGING either in release or debug version, so it’s always by
default. And we do use STL thoughout the code – containers, iterators,
functors.

 

I reviewed your linking error message again:

xxxd.lib(MLStaticUtil.obj)
: error LNK2038:
mismatch detected for ‘_ITERATOR_DEBUG_LEVEL’: value ‘2’ doesn’t match value
‘0’ in xx.obj

 

Basically, it has nothing to do with _HAS_ITERATOR_DEBUGGING directly, but instead a new preprocessor marco – _ITERATOR_DEBUG_LEVEL, which is new added in VS2010.
According to MSDN: The new _ITERATOR_DEBUG_LEVEL macro invokes debugging
support for iterators. Use this macro instead of the older _SECURE_SCL and _HAS_ITERATOR_DEBUGGING macros. So, if Softimage does want to disable checked iterator, you have to upgrade your build settings with using _ITERATOR_DEBUG_LEVEL !

 

After
revewing the source code of STL (in YVALS.H), you have to find the following:

 

#ifdef
__cplusplus

#ifndef _ALLOW_MSC_VER_MISMATCH

#pragma detect_mismatch(“_MSC_VER”, “1600”)

#endif /* _ALLOW_MSC_VER_MISMATCH */

#ifndef
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH

#if _ITERATOR_DEBUG_LEVEL == 0

#pragma
detect_mismatch(“_ITERATOR_DEBUG_LEVEL”, “0”)

#elif _ITERATOR_DEBUG_LEVEL == 1

#pragma
detect_mismatch(“_ITERATOR_DEBUG_LEVEL”, “1”)

#elif _ITERATOR_DEBUG_LEVEL == 2

#pragma detect_mismatch(“_ITERATOR_DEBUG_LEVEL”,
“2”)

#else

#error Unrecognized _ITERATOR_DEBUG_LEVEL
value.

#endif

#endif /* _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH */

#endif /* __cplusplus */

 

Please
notice the highlighted lines, again, detect_mismatch – new feature introduced in VS2010, where error LNK2038 is originated from. I can confirm this referring to MSDN: http://msdn.microsoft.com/en-us/library/ee956429.aspx

“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.”

 

So the impact of above code is that if several compile units (object files),
containing different value for _ITERATOR_DEBUG_LEVEL, linking will failed. By
default _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH is not defined, and I even cannot find this under MSDN, so it is obvious that VS2010 is trying to forbid the case
that several compile units with different _ITERATOR_DEBUG_LEVEL. Generally,
it’s a good design, as it effectively avoid the incorrect use of MS CRT library.

 

You may also ask me: I did not set _ITERATOR_DEBUG_LEVEL at all, why the link
complains about it? OK, here is the answer: as you set _HAS_ITERATOR_DEBUGGING=0, which causes _ITERATOR_DEBUG_LEVEL=0 implicitly. Again, code from YVALS.H.

 

#if
_HAS_ITERATOR_DEBUGGING

#define _ITERATOR_DEBUG_LEVEL 2

#elif _SECURE_SCL

#define _ITERATOR_DEBUG_LEVEL 1

#else

#define _ITERATOR_DEBUG_LEVEL 0

#endif

 

So in xxxd.lib, _ITERATOR_DEBUG_LEVEL is by default 2, while your cer.obj is
complied with _ITERATOR_DEBUG_LEVEL 0, the value is different cross these two
compile unit, thus linker stops work by throwing the error message – error LNK2038.

 

As a summary, the way to disable checked iterator in debug build
for Softimage without disabling/rebuilding MC3 debug version is just to set
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
so as to turn of mismatch checking.
The
only concern is that you lose the support to ensure the correct use of
dependency libraries.