简体   繁体   English

将 VS 2012 迁移到 VS 2015 后 C++ 项目中的 Xmemory 错误

[英]Xmemory errors in C++ project after migrating VS 2012 to VS 2015

My project works and compiles properly in Visual Studio 2012. However Im trying to open it in a computer with VS 2015 and I get 156 errors.我的项目在 Visual Studio 2012 中正常工作和编译。但是,我尝试在装有 VS 2015 的计算机中打开它,但出现 156 个错误。 All the same and all in the same file and same 3 lines: Severity Code Description Project File Line Suppression State全部相同,全部在同一个文件和相同的 3 行中:严重性代码描述项目文件行抑制状态

Error   C2338   The C++ Standard forbids containers of const elements because allocator<const T> is ill-formed. leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 585 

Error   C2535   'const long *std::allocator<_Ty>::address(const long &) noexcept const': member function already defined or declared    leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 613 

Error   C2535   'const long *std::_Wrap_alloc<std::allocator<_Ty>>::address(const long &) const': member function already defined or declared   leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 846 

I just get those same 3 errors 52 times each for a total of 156. Not a single error comes from my code, all are this xmemory0 file.我只得到 3 个相同的错误,每次 52 次,总共 156 次。我的代码没有一个错误,都是这个 xmemory0 文件。

I assume you're trying to use an STL container with const s?我假设您正在尝试使用带有const的 STL 容器? This is prohibited by C++ standard, but an earlier version of Visual C++ allowed this.这是 C++ 标准禁止的,但早期版本的 Visual C++ 允许这样做。 The new compiler is more standard compliant in this and will produce an error just like yours.新编译器在这方面更符合标准,并且会产生与您一样的错误。

More information at Visual Studio Connect Visual Studio Connect 上的更多信息

Might be possible to do a simple Find in Files for "<const" to check if there's anything like that in the whole source code.可能可以对 "<const" 执行简单的 Find in Files 以检查整个源代码中是否有类似的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM