Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 1.78 KB

enabling-debug-features-in-visual-cpp-d-debug.md

File metadata and controls

39 lines (33 loc) · 1.78 KB
titledescriptionms.datems.topicdev_langshelpviewer_keywordsauthorms.authormanagerms.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
CSharp
VB
FSharp
C++
/D_DEBUG compiler option [C++]
debugging [C++], enabling debug features
debugging [MFC], enabling debug features
assertions, enabling debug features
D_DEBUG compiler option
MFC libraries, debug version
debug builds, MFC
_DEBUG macro
mikejo5000
mikejo
mijacobs
debug-diagnostics

Enabling Debug Features in C++ projects (/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.

Related content

close