最近用cef,要debug调试,引用库时,提示:
LNK2038 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”
研究后的结论:这是因为,这个库的实现方式太老:
#if _HAS_ITERATOR_DEBUGGING
#define _ITERATOR_DEBUG_LEVEL 2
#elif _SECURE_SCL
#define _ITERATOR_DEBUG_LEVEL 1
#else
#define _ITERATOR_DEBUG_LEVEL 0
#endif
在预编译头下增加了_ITERATOR_DEBUG_LEVEL=2,依然报错。说要先有_HAS_ITERATOR_DEBUGGING
原来,在新的编译环境下,默认弃用_HAS_ITERATOR_DEBUGGING标志,见微软文档:
_HAS_ITERATOR_DEBUGGING | Microsoft Learn详细了解:_HAS_ITERATOR_DEBUGGINGhttps://learn.microsoft.com/zh-cn/cpp/standard-library/has-iterator-debugging?view=msvc-170
解决方案:
预编译头上,加入_HAS_ITERATOR_DEBUGGING,如图