User forums > Using Code::Blocks
Changing build target according to a #define
(1/1)
Lefteris:
Hello,
I did a quick search but could not find an answer to my question so I will ask about it here. I have a project which depending on a #define flag should compile different files. Later in the future when I will distribute it I guess I will have to include a normal makefile but for now I would like to use the pre-build script step of Codeblocks. I have made 4 different virtual build targets (2 debug and 2 release). I can not understand what syntax I should use in the pre-script. A pseudocode would be
--- Code: ---if(DEBUG) { if(FLAG_DEFINED){Build Debug_FD }else{Build Debug} }
else { if(FLAG_DEFINED){Build Release_FD }else{Build Release} }
--- End code ---
I do know ofcourse that I can just pick the builds from the drop down menu on the top left of the Codeblocks GUI, but since it should be later done by a makefile I want to test it this way too. Hope I make sense.
scarphin:
In 'project/build options/compiler settings/#defines' for a specific target u can insert ur definition like
--- Code: ---FLAG_DEFINED
--- End code ---
Then in the source insert
--- Code: ---#ifdef FLAG_DEFINED
do this
#else
do that
#endif
--- End code ---
That's what I understand from ur post, sry if unrelated.
Navigation
[0] Message Index
Go to full version