• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

#ifdef in CodeWarrior Pro 5

zChris

Member
Hello!

This maybe a stupid question but i have searched and cannot find if CodeWarrior IDE 4 (CodeWarrior PRO 5 suite) supports conditional compilation instructions (macros).

So my question is if it supports #ifdef X and in that case how do i invoke the compiler with those options?

An example for gcc would be "gcc -D macro".

Thanks.
 

cheesestraws

Well-known member
#ifdef X definitely does exist and works.

What I'm unsure of is where the UI to set which Xes are defined on a per-target basis lives, if it exists at all. It would be totally possible, but annoying, that the only way to define names would be to have #defines in the source code.

You can set a prefix file in the C compiler options, I note: so one way around this would be to have a header file that contains your #defines and set it as a prefix. That gets ... hairier in multi-target situations, but what doesn't?

Sorry this isn't more use.
 

buserror

Active member
You can easily create a 'top header' as a precompiled header with whatever you like to define in there... This will be "included" in every file you compile.
 
Top