Visual c++ VC++;:代码在VS2010中工作,在VS2013中中断

Visual c++ VC++;:代码在VS2010中工作,在VS2013中中断,visual-c++,visual-studio-2013,msvcrt,Visual C++,Visual Studio 2013,Msvcrt,编辑:与投票结束时的问题不同,这里的违规代码是CRT代码,而不是我的。即使它有问题(我很确定它没有),我也无法修复它的来源 我们有一些遗留内存泄漏跟踪代码,它使用了一些CRT内部(没有什么太奇怪的东西,本质上是_CrtMemBlockHeader)。在尝试从VS2010迁移到VS2013时,代码似乎会导致零星的构建失败,而有问题的部分可以归结为: #include <windows.h> #define _CRTBLD #include <..\crt\src\dbgint

编辑:与投票结束时的问题不同,这里的违规代码是CRT代码,而不是我的。即使它有问题(我很确定它没有),我也无法修复它的来源


我们有一些遗留内存泄漏跟踪代码,它使用了一些CRT内部(没有什么太奇怪的东西,本质上是_CrtMemBlockHeader)。在尝试从VS2010迁移到VS2013时,代码似乎会导致零星的构建失败,而有问题的部分可以归结为:

#include <windows.h>

#define _CRTBLD
#include <..\crt\src\dbgint.h>

#include <fstream>
void Func()
{
    std::ofstream myfile;
    myfile << 8;
}
#包括
#定义
#包括
#包括
void Func()
{
std::流myfile;
myfile c:\program files(x86)\microsoft visual studio 12.0\vc\include\xlocnum(1105):警告C4273:“id”:dll链接不一致
1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\xlocnum(80):请参阅“public:static std::locale::id std::numpunct::id”的先前定义
1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\xlocnum(80):编译类模板静态数据成员'std::locale::id std::numpunct::id'
1> 与
1>          [
1> _Elem=char
1>          ]
1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\xlocnum(1185):请参阅正在编译的函数模板实例化“const\u Facet&std::use\u Facet(const std::locale&)”的参考
1> 与
1>          [
1> _Facet=std::numpunct
1> ,_Elem=char
1>          ]
1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\xlocnum(1179):在编译类模板成员函数“std::ostreambuf_迭代器std::num_put::do_put(_OutIt,std::ios_base&,_Elem,std:_Bool)const”时
1> 与
1>          [
1> \u OutIt=std::ostreambuf\u迭代器
1> ,_Elem=char
1>          ]
1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\ostream(306):请参阅正在编译的类模板实例化“std::num\u put”的参考

1> c:\ProgramFiles(x86)\microsoft visual studio 12.0\vc\include\ostream(292):当编译类模板成员函数“std::basic_ostream&std::basic_ostream::operator在我的系统上查看此错误时,它似乎只与
\define\u CRTBLD
fstream
头相关。包含的
dbgint.h
无关(您可以注释掉
#include
,仍然会得到相同的错误

因此,
fstream
标题中似乎存在问题。更改包含顺序将删除编译错误:

#include <windows.h>
#include <fstream>

#define _CRTBLD
#include <..\crt\src\dbgint.h>
#包括
#包括
#定义
#包括

也许这会有帮助?

我以前来过这里……确保你有所有的标题
#include
ed。VS2010自动
#include
标题,但VS2013不会这样做。(1)VS2010/2013使用相同的设备解析include(使用不同的CRT标题文件夹),(2)错误本身不是“undefined symbol”/“missing type specifier”等家族的错误,因此-这不太可能是标题包含问题。尝试:我没有投票关闭它,请不要侮辱。我道歉,感谢您花时间尝试和帮助。这些下意识的向下投票/关闭投票对我来说真的很烦人。我刚刚看到了我原来的cOMENT没有出现-谢谢,这或多或少是我最终使用的解决方案。我没有更改包含顺序,而是在包含dbgint后立即“undef'd”CRTBLD。
#include <windows.h>
#include <fstream>

#define _CRTBLD
#include <..\crt\src\dbgint.h>