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 do not need to define _DEBUG in your code, however. Passing the /D_DEBUG flag on the compiler command line defines _DEBUG (if you create your project in Visual Studio using wizards, this is done 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.

See Also

Debugging Visual C++ | Changing Project Settings for a C or C++ Debug Configuration