News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Constant definitions for debug, release etc

Started by scarphin, April 14, 2011, 11:23:34 AM

Previous topic - Next topic

scarphin

Is there any constants defined when a specific build target is chosen? I mean does CB define anything automatically? I'm trying to compile build target specific code like below:

#if defined DEBUG (can be something CB defines)
    do this;
#elif defined RELEASE (same here)
    do that;

I know I can define them manually but I want to use what CB defines if there is any. Thnx...

Jenna

Inside C::B the "$target"-variable contains the name of the active build-target.

scarphin

I couldn't think of a way to use it, I guess it won't work when injected into the source like '$target'. So how can I make a constant out of it?

oBFusCATed

Quote from: scarphin on April 14, 2011, 11:23:34 AM
I know I can define them manually but I want to use what CB defines if there is any. Thnx...
There are no automatic/automagic defines, you have to add all you defines in project -> build options -> [target] -> compiler -> defines
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

scarphin

Quote from: oBFusCATed on April 14, 2011, 12:32:53 PM
Quote from: scarphin on April 14, 2011, 11:23:34 AM
I know I can define them manually but I want to use what CB defines if there is any. Thnx...
There are no automatic/automagic defines, you have to add all you defines in project -> build options -> [target] -> compiler -> defines
Well, I'm not looking for magic, that was what I was looking for. ;) One last question, I've searched but couldn't find and specific information about this. How do I define a constant in project -> build options -> [target] -> compiler -> defines?
Is it like
'#define DEBUG 1'
or just
'DEBUG 1'
or how?

killerbot

either you just define it, aka value doesn't matter :


DEBUG


or you give it a value


DEBUG=1



scarphin

Ok got it. Maybe because I'm a noob but the work u have done with codeblocks still continues to impress me in every detail. ;) Thnx...

killerbot

fyi : the common convention is in the release build to define NDEBUG, and don't define anything in debug build.

scarphin

Yup I know, I guess it's because of the 'assert' macro. ;) Thnx anyway.