title | description | ms.date | ms.topic | dev_langs | helpviewer_keywords | author | ms.author | manager | ms.subservice | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Enabling Debug Features in C++ projects (-D_DEBUG) | In Visual C++ you enable debugging features by defining _DEBUG. Learn how to do this, and learn how to link an MFC program in order to debug it. | 11/04/2016 | conceptual |
|
| mikejo5000 | mikejo | mijacobs | debug-diagnostics |
In Visual C++, debugging features such as assertions are enabled when you compile your program with the symbol _DEBUG defined. You can define _DEBUG in one of two ways:
Specify #define _DEBUG in your source code, or
Specify the /D_DEBUG compiler option. (If you create your project in Visual Studio using wizards, /D_DEBUG is defined automatically in the Debug configuration.)
When _DEBUG is defined, the compiler compiles sections of code surrounded by #ifdef _DEBUG and
#endif
.The Debug configuration of an MFC program must link with a Debug version of the MFC library. The MFC header files determine the correct version of the MFC library to link with based on the symbols you have defined, such as _DEBUG and _UNICODE. For details, see MFC Library Versions.