Codeblocks debug preprocessor

c++, c-preprocessor, codeblocks

Solution

Do I have to define DEBUG on my own and change it, everytime I change the Building-Target, or is there a word I don't know?

I don't know what, if anything is set by default by Code::Blocks. But, if you define your own #defines

Project->Build options...->[Debug|Release]->#defines 

you don't have to change them as you switch between build targets (DEBUG or RELEASE). It lets you define values that are specific to the Debug build, as well as values that are specific to the Release build.

To avoid having to manually enter it each time for each new project you can make a small project with just your Debug/Release #defines and save that as a project template and then create new projects from that project template.

Problem

I'm writing a C++ Program with Codeblocks and for debugging-purposes I need to know if the Building-Target of Codeblocks is set to "DEBUG" or to "RELEASE". I already tried this: ``` #ifdef DEBUG printf("Debug-Message"); #endif ``` and this ``` #ifdef _DEBUG printf("Debug-Message"); #endif ``` But none of this words are defined. Do I have to define DEBUG on my own and change it, everytime I change the Building-Target, or is there a word I don't know?

Original source