The compiler defines _DEBUG when you specify the /MTd or /Mdd option. These options specify debug versions of the C runtime library.
For more information, see Using C Run-Time Library Debugging Support.