In case there are problems with the C/C++ preprocessor, it is useful to generate the compiler preprocessor listing. Here is how to create a preprocessor listing with GNU gcc compiler and the GNU ARM Eclipse plugins in Eclipse:
In the project settings, turn on the -E option (Preprocess only):
That option will direct the compiler to do preprocessing only, and to stop after that (i.e. not producing object files). Typically, I select that option for the whole project, but of course I can do that for a single file too.
Make sure that the file for which you need the preprocessing is compiled: touch the file or do a Project > Clean to force a full rebuild.
This will just do the preprocessing and produce the preprocessing listing files. Because no object files are generated, linking will fail.
There is one trick to know about it: the preprocessed files produced have the .o (like object files) extension:
Open the file with the text editor:
Now I can see what the listing is:
At the end, to not forget to remove the -E option and to do a Project > Clean again to build the project as usual.
Happy Preprocessing π
Erich, please use only the new links to GNU ARM Eclipse (http://gnuarmeclipse.github.io), at a certain moment the old addresses (with livius.net) will no longer be forwarded.
LikeLike
thanks, I still have that old link in my list of links, and WordPress suggests it as the first entry π¦
LikeLike
You could also use ‘-save-temps=obj’ [1]. That will compile the project as usual, but also keep the preprocessed file (.i) and the assembly file (.s) in the directory where the object files are stored. Sadly there is no easy option to activate this in Eclipse.
[1] https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
LikeLike
I have not tried that, but this topic is discussed/mentioned here:
https://sourceforge.net/p/gnuarmeclipse/feature-requests/37/
LikeLike
Pingback: How to Use Eclipse CDT Environment Variables in C/C++ Code | MCU on Eclipse