【问题标题】:Does crtdbg.h conflict with DirectX?crtdbg.h 是否与 DirectX 冲突?
【发布时间】:2012-06-10 14:29:02
【问题描述】:

我刚刚发现了隐藏的宝石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 覆盖 new 运算符时,它破坏了 DirectX SDK 中的某些内容(如果您没有注意到错误,我使用的是 DirectX 11 SDK)。有这样的记录吗?几次搜索没有产生任何结果。我真的希望我可以继续使用这些内存调试工具,任何解决方法都将不胜感激!

【问题讨论】:

  • 无复制。使用 C/C++、预处理器、生成预处理文件选项。打开生成的 .i 文件,找到 _D3DXMATRIXA16 并发布您看到的内容。并记录版本号。
  • @HansPassant 我没有看到那个选项,我能看到的最接近的是“预处理到文件”,但它告诉我找不到“base.obj”,这是我的base.h/base.cpp 文件。不过我解决了。
  • 这是一个链接器错误。很难帮你。
  • @HansPassant 没关系,我修好了。我不知道链接器错误来自哪里,除了它仅在我使用该设置时发生。

标签: c++ directx crtdbg.h


【解决方案1】:

好的,我想通了。我找到了this post via Google.(我希望 Stack Overflow 在我输入此内容时在侧边栏上向我展示了它!或者它确实展示了它但我错过了它......)。

基本上,我需要将crtdbg.hstdlib.h的包含和_CRTDBG_MAP_ALLOC的定义移动到单独的标题中,并使用C/C++下的Forced Include File选项 > 高级在项目属性页面中强制包含文件无处不在。这似乎使它覆盖了所有其他 new 覆盖。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多