Preprocessor Listing for GNU gcc with GNU ARM Eclipse Plugins

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:

Preprocessor Listing in Eclipse

Preprocessor Listing in Eclipse

In the project settings, turn on the -E option (Preprocess only):

Preprocessor -E Option

Preprocessor -E Option

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:

Preprocessor listing file but with object file extension

Preprocessor listing file but with object file extension

Open the file with the text editor:

Open with text editor

Open with text editor

Now I can see what the listing is:

Preprocessor Listing

Preprocessor Listing

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 πŸ™‚

Advertisements

4 thoughts on “Preprocessor Listing for GNU gcc with GNU ARM Eclipse Plugins

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s