0

I am trying to use Visual Leak Detector in my C++ application (using visual studio 2013), and after reading the documentation and modifying Include Directories and Library Directories of a project, I am adding vld.h header in one of my cpp files. As written in the documentation I have to add it after all the precompiled headers in the source. But while building the project after adding the header in my source code I am getting following error:

[VLD COMPILE ERROR] #include "vld.h" should appear before #include <afxwin.h> in file stdafx.h

Header File Position Message

so when I add it in the stdafx.h header file, the project builds but I get a runtime error saying: Unhandled exception at some_memory_location (vld_x64.dll) in product_debug_build.exe. Access violation reading location some_memory_location

Access Violation Error

And when I put it before precompiled headers in any of my cpp files, then the build skips the inclusion of the header file vld.h.

Skipped

But I don't get this message when I build the whole solution, but then it doesn't work (probably because I am adding it before precompiled headers ?).

What am I doing wrong here?

StewieGGriffin
  • 349
  • 1
  • 4
  • 14
  • Try to put `vld.h` to `StdAfx.h` header file as you did and then into your source file where precompiled headers are used. – Licensed Slacker May 07 '18 at 07:04
  • @LicensedSlacker Already did that, that way it builds and doesn't give any runtime exception error but doesn't show any leak, even if I manually introduce leaks. – StewieGGriffin May 07 '18 at 07:09
  • Is this a MFC application? – Licensed Slacker May 07 '18 at 07:16
  • @LicensedSlacker Yes, a large portion of the project does use MFC. It is a huge codebase. By huge, I mean think of the codebase you might have for a database such as Oracle. – StewieGGriffin May 07 '18 at 07:30
  • Did some testing with VS2015 and VLD 2.5.1, but I did not find any issues in VLD use. I had `vld.h` in my `StdAfx.h` before anything else and it was everything what was required. https://stackoverflow.com/questions/21721088/visual-leak-detector-not-reporting-leaks?rq=1 mentioned some compatibility issues with VC2013 but those should be solved already. – Licensed Slacker May 07 '18 at 08:21

0 Answers0