User forums > Using Code::Blocks

Constant definitions for debug, release etc

(1/2) > >>

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...

--- End quote ---
There are no automatic/automagic defines, you have to add all you defines in project -> build options -> [target] -> compiler -> defines

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...

--- End quote ---
There are no automatic/automagic defines, you have to add all you defines in project -> build options -> [target] -> compiler -> defines

--- End quote ---
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?

Navigation

[0] Message Index

[#] Next page

Go to full version