User forums > Using Code::Blocks

Question about conditionnal variables settings

(1/1)

SamSam:
Hi,

Let's say that on my project I have a "Project build option / Custom variables" called "VarType" which is filled by user
"VarType" can be equal to "ABC" or "DEF".

I would like to use a different compilation switch depending on VarType (so that is is activated without user needs to remember it).
For instance:
- if "VarType =  ABC" then we add -DBLABLA in compiler toolchain.
- if "VarType =  DFE" then we add -DBLUBLU in compiler toolchain.


I tried to do it in #defines folder doing something like this:

$if($VarType = ABC){BLABLABLA}{BLUBLU}

or

$if($VarType == ABC){BLABLABLA}{BLUBLU}

But it does not work fine.

Is there a way to do it or can $if() be used only without any statement in it? (= only checking if value is 0 or something).

If not possible do you have another idea of how I could do it?





BlueHazzard:
The

--- Code: ---$if(){}{}
--- End code ---
macro is completely broken: https://sourceforge.net/p/codeblocks/tickets/520/

If there are no future objections i will commit them in the next two days, then your use case should work

SamSam:
It would be great! Thanks!   :)

Navigation

[0] Message Index

Go to full version