2012-06-10 71 views
1

我刚刚发现了隐藏的宝石crtdbg.h,这使得内存泄漏检测更容易。不幸的是,当我今天将DirectX链接到我的程序中时,出现了一些我从未见过的错误。crtdbg.h与DirectX冲突吗?

1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.h(425): error C2059: syntax error : 'constant' 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.h(425): error C2091: function returns function 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.h(425): error C2802: static member 'operator new' has no formal parameters 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.h(426): error C2059: syntax error : 'constant' 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.h(426): error C2090: function returns array 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.inl(1003): error C2761: 'void *(__cdecl *_D3DXMATRIXA16::operator new(void))(size_t)' : member function redeclaration not allowed 
1>e:\program files (x86)\microsoft directx sdk (june 2010)\include\d3dx10math.inl(1003): fatal error C1903: unable to recover from previous error(s); stopping compilation 

看来当crtdbg覆盖新的运营商一样,它打破在DirectX SDK的东西(如果你没有在错误的通知,我使用DirectX 11 SDK)。有没有这样的记录?一些搜索没有产生任何结果。我真的希望我可以继续使用这些内存调试工具,并且非常感谢任何解决方法!

+0

无再现。使用C/C++,预处理器,生成预处理文件选项。打开生成的.i文件,找到_D3DXMATRIXA16,并发布你看到的内容。和文件版本号。 –

+0

@HansPassant我没有看到这个选项,我能看到的最接近的是“Preprocess to a File”,但它告诉我它找不到“base.obj”,它是我的base.h/base.cpp文件。然而,我解决了它。 – smoth190

+0

这是一个链接器错误。很难帮助你。 –

回答

1

好吧,我想通了。我发现this post via Google.(我希望Stack Overflow在我打字时在侧边栏上显示了它,或者它可以,我错过了...)。

基本上,我需要移动包括crtdbg.hstdlib.h_CRTDBG_MAP_ALLOC到一个单独报头中的定义,并下使用Forced Include File选项C/C++ >>高级在项目属性页强制将包含文件到处。这似乎使其覆盖所有其他new覆盖。