1

I just discovered the hidden gem crtdbg.h which makes memory leak detection so much easier. Unfortunately, when I linked DirectX into my program today, I got some errors I've never seen before.

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

It seems like when crtdbg overrides the new operator, it breaks something in the DirectX SDK (in case you didn't notice in the errors, I am using the DirectX 11 SDK). Is anything like this documented? A few searches didn't yield any results. I really hope I can continue to use these memory debugging tools, and any workarounds would be greatly appreciated!

smoth190
  • 438
  • 7
  • 26
  • No repro. Use the C/C++, Preprocessor, Generate Preprocessed File option. Open the generated .i file, find _D3DXMATRIXA16 back and post what you see. And document version numbers. – Hans Passant Jun 10 '12 at 14:55
  • @HansPassant I don't see that option, the closest thing I can see is "Preprocess to a File", but it tells me it can't find "base.obj", which is my base.h/base.cpp file. I solved it, however. – smoth190 Jun 10 '12 at 19:17
  • That's a linker error. Hard to help you. – Hans Passant Jun 10 '12 at 19:47
  • @HansPassant Its ok, I fixed it. I don't know where the linker error came from, other than the fact that it only happened when I used that setting. – smoth190 Jun 10 '12 at 19:58

1 Answers1

1

Ok, I figured it out. I found this post via Google. (I wish Stack Overflow had shown it to me on the sidebar when I was typing this! Or maybe it did and I missed it...).

Basically, I need to move the including of crtdbg.h, stdlib.h and the definition of _CRTDBG_MAP_ALLOC to a separate header, and use the Forced Include File option under C/C++ >> Advanced in the project properties page to force that include file everywhere. This seems to make it override all other new overrides.

Community
  • 1
  • 1
smoth190
  • 438
  • 7
  • 26