In this post I have found settings for Eclipse Indexer to show the state if defines correctly. Usually I have something like this in my projects:
So I define the macro
DEBUG_ME on the compiler command line. And it is cool to see that the Eclipse editor correctly grays out the code which is not enabled. But for this the Eclipse Editor view needs to know about the macro, but how does this work?
The reality is: that works out of the box for many tool chains, but not for all.
Kinetis ARM gcc
It works perfectly for the ARM gcc as in MCU10.3. And it works because the editor knows that this symbol is defined in the Path and Symbols information of the project:
This, because this symbol is added automatically to the symbols list, because I have defined it in the compiler preprocessor settings for the Kinetis ARM gcc compiler:
Without going into the details: The Eclipse Managed Make framework and option settings offers the above -D control, and if used by the build tool panels, the options are automatically added/removed from the symbols.
Freescale (non-gcc) ARM/Kinetis Compiler
That feature exists as well for the Freescale (non-gcc) ARM/Kinetis compiler under ARM Compiler > Input:
Freescale S08 Compiler
The same thing is found for the S08 compiler under HCS08 Compiler > Preprocessor:
Freescale ColdFire Compiler
Unfortunately (at least up to MCU10.3 beta) such a panel is not present for the Freescale ColdFire compiler. I can use the -d compiler option to pass my defines:
But: this has no meaning for the Eclipse editor. The compiler knows about the symbol, but not the Editor view. And because this managed make integration into eclipse is not using the panels as shown above, the # Symbols tab is missing too, so I cannot add manually a symbol? 😦
I have filed a feature request, so hopefully this could be added. Until then, the Eclipse editor view is innocent and does not know what I have defined on the compiler side.
💡 If you have found a solution for that problem, then please post a comment 🙂
A similar story for the PowerPC compiler. There is no separate settings for preprocessor defines, but can be added using the -d option as shown below:
The option -d DEBUG_ME=1 is equivalent to have
#define DEBUG_ME 1
in all sources. What that compiler Eclipse integration offers is to specify a prefix file: instead of passing the defines on the command line, they are put in a normal text file:
The way how to specify compiler defines is different from compiler to compiler. At least there is a command line options common to all of them. But only using the Eclipse CDT special panel for defines ensures that Eclipse is aware of the symbol definition.
Happy Defining 🙂