Siavoshkc
Siavoshkc

Reputation: 342

Why setting DEBUG_NEW in an MFC app can cause compiler error

Here says that you may put DEBUG_NEW in place of new in your MFC app. When I do so the compiler says that DEBUG_NEW is not defined. It is VS 2017. _DEBUG is defined. What can be wrong?

[edit] I should note first I placed it as a global define for the whole project. There were thousands of errors (it is a big project). Then I changed just one occurrence. One that was in my code. And it is not working. is included but is not directly

Upvotes: 1

Views: 187

Answers (1)

Joseph Willcoxson
Joseph Willcoxson

Reputation: 6050

You need to be more specific. Where are you placing it?

In a newly generated MFC app, they usually put these lines in the .cpp files after the includes (see last 3 lines):

// LangInfo.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "LangInfo.h"
#include "LangInfoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

Upvotes: 1

Related Questions