在Visual Studio 2017中使用Platform Toolset v141进行调试64位编译后,我遇到了问题。
typedef std::map<int, msclr::gcroot<cli::array<short>^>> MapIntToManaged;
int main(array<System::String ^> ^args)
{
MapIntToManaged testMap;
for (auto &it : testMap) {}
return 0;
}
这会导致链接器错误
error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._Tree_unchecked_const_iterator< ?? :: ?? >): (0x02000048).
1>LINK : fatal error LNK1255: link failed because of metadata errors
我找到了一些解决此错误的解决方法:
使用此语法代替 auto 迭代器:
for (MapIntToManaged::iterator it = testMap.begin(); it != testMap.end(); ++it) {}
我想了解这个问题。 我想使用最新的工具集,新的迭代器语法和Debug运行时DLL。