Search code examples
ceclipse-cdtiar

Is there a way to #define a C macro that is only defined while in an Eclipse editor window?


I'm using Eclipse Galileo with CDT for C development targeting embedded devices.

Like so many other compilers targeted at µcontrollers, the IAR compiler uses some non-standard variable types that Eclipse/CDT doesn't recognize and flags them as problems. Since these variable types are the foundations of other variable types I use the problem cascades to the point that just about every line using variables declared with the non-standard types are flagged as having syntax problems, even when the syntax is correct. It's not a critical problem, but it is definitely a nuisance.

  1. Is there a setting within Eclipse/CDT where I can add non-standard syntax, or...

  2. Is there some predefined macro within Eclipse/CDT that I can access with something like #ifdef SECRET_ECLIPSE_MACRO ... for conditionally setting or clearing a macro with the string of the offending variable type definition?


Solution

  • Well, you can go the other way around. Define a NOT_ECLIPSE macro when you compile your code, and check for its non-existence in your code. If it's not defined, you're in Eclipse.