This documentation is archived and is not being maintained.

Enabling Debug Features in Visual C++ (/D_DEBUG)

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.