Enabling memory leak location reporting with _CRTDBG_MAP_ALLOC

Hi there!

According to CRT docs here, all one needs to do to get source location of a memory leak is to define _CRTDBG_MAP_ALLOC.

Without this, reports are printed but without the allocation source / line number so sort of hard to track down - which seems to be the default for VST SDK.

So I’ve tried adding #define _CRTDBG_MAP_ALLOC to my project but this produces following errors:

1>C:\apps\VST_SDK\vst3sdk\vstgui4\vstgui\lib\cstring.h(167,1): error C2059: syntax error: 'constant' (compiling source file <redacted>)
1>C:\apps\VST_SDK\vst3sdk\vstgui4\vstgui\lib\cstring.h(167,1): error C2059: syntax error: 'constant' (compiling source file <redacted>)

The section that appears to be causing error is:

164  namespace String {
165   	VSTGUI_DEPRECATED(/** @deprecated Allocates a new UTF8StringBuffer with enough size for string and copy the string into it. Returns nullptr if string is a nullptr. */
166   	UTF8StringBuffer newWithString (UTF8StringPtr string);)
167   	VSTGUI_DEPRECATED(/** @deprecated Frees an UTF8StringBuffer. If buffer is a nullptr it does nothing. */
168   	void free (UTF8StringBuffer buffer);)
169   }

The clues are there - (malloc and free are already redefined?) and C2059 description supports this.

So my question - is there a way to get proper CRT mem leak reporting with or without _CRTDBG_MAP_ALLOC?

Many thanks in advance

free is redefined here by Microsoft!!!: you could disable the VSTGUI Deprecated stuff by defining VSTGUI_ENABLE_DEPRECATED_METHODS