1

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

Siavoshkc
  • 346
  • 2
  • 16
  • I know it is a very unspecific question but don't know what information to give. Platform toolset is v141 and Windows SDK is v10.0.16299.0 – Siavoshkc Apr 01 '20 at 21:37
  • 1
    You wrote: *You see first I placed it as a global define for the whole project*. You should update your question. Also note what @Joseph Willcoxson wrote. Look at the files you got when you created the project, they already had `DEBUG_NEW` defined. You would only do this for new `.cpp` files that you add. Do it the same way the existing files do it. Do it the way it should be done and it will work. – lakeweb Apr 02 '20 at 19:09

1 Answers1

1

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
Joseph Willcoxson
  • 5,853
  • 1
  • 15
  • 29
  • You see 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. – Siavoshkc Apr 01 '20 at 21:30
  • 1
    You haven't really showed us anything that we can help with. We're just making guesses. Generate a test MFC app and look how MS does it. It's in every MFC App Wizard generated application. – Joseph Willcoxson Apr 02 '20 at 15:47