Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ x C+中的内存错误+;将VS 2012迁移到VS 2015后的项目_C++_Visual Studio_Visual Studio 2012_Compiler Errors_Visual Studio 2015 - Fatal编程技术网

C++ x C+中的内存错误+;将VS 2012迁移到VS 2015后的项目

C++ x C+中的内存错误+;将VS 2012迁移到VS 2015后的项目,c++,visual-studio,visual-studio-2012,compiler-errors,visual-studio-2015,C++,Visual Studio,Visual Studio 2012,Compiler Errors,Visual Studio 2015,我的项目在Visual Studio 2012中正常运行并编译。然而,我试图用VS 2015在计算机上打开它,我得到156个错误。所有相同的文件和相同的3行: 严重性代码说明项目文件行抑制状态 Error C2338 The C++ Standard forbids containers of const elements because allocator<const T> is ill-formed. leaf c:\program files (x86)\micr

我的项目在Visual Studio 2012中正常运行并编译。然而,我试图用VS 2015在计算机上打开它,我得到156个错误。所有相同的文件和相同的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 
<代码>错误C23 38,C++标准禁止分配器的容器,因为分配器的格式不正确。叶c:\ProgramFiles(x86)\microsoft visual studio 14.0\vc\include\xmemory0 585 错误C2535“const long*std::allocator::address(const long&)noexcept const”:成员函数已定义或声明为叶c:\program files(x86)\microsoft visual studio 14.0\vc\include\xmemory0 613 错误C2535“const long*std::_Wrap\u alloc::address(const long&)const”:成员函数已定义或声明为叶c:\program files(x86)\microsoft visual studio 14.0\vc\include\xmemory0 846
我只是得到同样的3个错误,每次52次,总共156次。我的代码中没有一个错误,都是这个xmemory0文件。

我假设您试图使用带有
const
s的STL容器?这是C++标准禁止的,但是Visual C++的早期版本允许这样做。新的编译器在这方面更符合标准,并且会产生与您一样的错误

更多信息请访问


也许可以在文件中进行简单的查找“请不要试图在STL容器或常量中保存对某个对象的引用?”SamiKuhmonen似乎已经解决了这个问题,不过如果有人知道跟踪这些问题来源的任何方法,我将不胜感激(错误不会显示它们发生在哪个文件中)第一次尝试是在文件中查找,如果不是我在代码中得到的错误,而不是在这个文件中的话,@ USSR1313929不一定。模板是复杂的,很多时候用C++来显示错误,而错误在我们的代码中,即使错误在我们的代码中。如果是这样的话,我怎么调试它?这是一个PRO。我和另外4个人一起工作,他们都使用Xcode。这已经持续了一年半。询问每个人在任何文件中是否做过类似的事情……有点困难(同样值得一提的是,它在Xcode中正确编译)@ USER 313929在这种情况下,它是一个有点困惑和难以找到,除非你发现任何const /引用容器内。谢谢!这是我做的。我对C++没有太多的经验,所以我不太确定我怎么能搜索这个。它最终是两个长常量列表!谢谢你的伙伴,你的解释真的很有帮助。告诉我不仅要解决问题,还要理解它。