Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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.

Community Additions

© 2015 Microsoft