Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is DEBUG_NEW

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I'm writing a win32 app (no MFC), and I am allocating memory in it. Whenever I created a new class, I let the compiler to create the correct .h and .cpp. I noticed at the top of every .cpp file it has these lines of code:

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

This didn't seem to hurt anything, so I ignored them. However, later I needed to allocate memory. I get the following error message on a line that looks like this:

m_lpStr = new TCHAR[len];
error C2065: 'DEBUG_NEW' : undeclared identifier

I deleted the wierd code and it works fine now, but I don't want to delete something that may be necessary somewhere else. What exactly is this trying to do? Is the problem that I am not using MFC?
 
It's an "alternative" way of allocating, which only happens in debug builds:

You get those warnings in the debug window if you've forgotten to release memory. That's all it does....

Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top