Article ID: 141493
Article Last Modified on 12/2/2003
#ifdef _DEBUG
inline void* __cdecl operator new(unsigned int s)
{ return ::operator new(s, _CLIENT_BLOCK, __FILE__, __LINE__); }
#endif"
__FILE__ and __LINE__ are macros defined by the compiler that report the
current file name and line number. Macros are filled out by the
preprocessor; then the compiler replaces your call to new with this
function. Therefore, the macros have already been filled out before they
are inlined. Hence, they will report the header file information not the
actual source location.
-or-
/* MyDbgNew.h
/* Defines global operator new to allocate from
/* client blocks
*/
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif // _DEBUG
/* MyApp.cpp
/* Compile options needed: /Zi /D_DEBUG /MLd
/* or use a
/* Default Workspace for a Console Application to
/* build a Debug version
*/
#include "crtdbg.h"
#include "mydbgnew.h"
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif
void main( ) {
char *p1;
p1 = new char[40];
_CrtMemDumpAllObjectsSince( NULL );
}
Keywords: kbvc400 kbvc410 kbvc420 kbvc500 kbvc600 kbcrt kbdocerr kbcode KB141493