Add opt-in leak detection under MSVC + Windows.

Closes #439
This commit is contained in:
Martin Hořeňovský 2017-02-16 11:09:09 +01:00
parent c6178601c5
commit d8230a8d4d
2 changed files with 17 additions and 0 deletions

View file

@ -10,8 +10,22 @@
#ifndef __OBJC__
#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
#include <crtdbg.h>
#endif
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
flag |= _CRTDBG_LEAK_CHECK_DF;
flag |= _CRTDBG_ALLOC_MEM_DF;
_CrtSetDbgFlag(flag);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
// Change this to leaking allocation's number to break there
_CrtSetBreakAlloc(-1);
#endif
int result = Catch::Session().run( argc, argv );
return ( result < 0xff ? result : 0xff );
}