Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: SamSam on May 17, 2019, 09:41:41 am

Title: Question about conditionnal variables settings
Post by: SamSam on May 17, 2019, 09:41:41 am
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?





Title: Re: Question about conditionnal variables settings
Post by: BlueHazzard on May 18, 2019, 11:59:59 am
The
Code
$if(){}{}
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
Title: Re: Question about conditionnal variables settings
Post by: SamSam on May 20, 2019, 09:34:30 am
It would be great! Thanks!   :)