Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » How to generate one output file including all include files and the source file(Can the Eclipse compiler genereate one C output file including all the include files and the souce code file?)
How to generate one output file including all include files and the source file [message #1744368] Mon, 26 September 2016 11:14 Go to next message
Søren Bonefeld is currently offline Søren BonefeldFriend
Messages: 3
Registered: September 2016
Junior Member
I am having a problem with my compiler.

My source file consists of many include files with conditional includes and conditional source code lines in the source code file.

To find the error I would like to have just one file with all the compiled source code lines from the include files code and the source file.

Is there an compiler setting for that somewhere?

I hope that you can help me.


Re: How to generate one output file including all include files and the source file [message #1744393 is a reply to message #1744368] Mon, 26 September 2016 13:07 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Never encountered an Eclipse option to do this. The file can be potentially huge as many library headers are large.

Most compilers have an option save the preprocessor output and to stop after the preprocessor has run. GCC has one as does the Microsoft compiler. If yours doesn't, maybe you can download one that does.

[Updated on: Mon, 26 September 2016 17:07]

Report message to a moderator

Re: How to generate one output file including all include files and the source file [message #1744441 is a reply to message #1744393] Tue, 27 September 2016 06:10 Go to previous messageGo to next message
Søren Bonefeld is currently offline Søren BonefeldFriend
Messages: 3
Registered: September 2016
Junior Member
I am using the Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 2
Build id: 20140212-2123

How do I save the preprocesser output to a file?
Do I have to download a utility or is it a setting in the IDE?

Re: How to generate one output file including all include files and the source file [message #1744442 is a reply to message #1744441] Tue, 27 September 2016 06:14 Go to previous messageGo to next message
Søren Bonefeld is currently offline Søren BonefeldFriend
Messages: 3
Registered: September 2016
Junior Member
Thank you for your help David. It is much appreciated.

Re: How to generate one output file including all include files and the source file [message #1744453 is a reply to message #1744442] Tue, 27 September 2016 07:52 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Saving it depends on the compiler.
GCC for example writes the output to stdout so it must be captured.
GCC command: gcc -E somefile.cpp > somefile.txt
Or you could use: gcc -E somefile.cpp -o somefile.txt

It's easier if you do this outside of Eclipse if it's for only one file.
But, if Eclipse is building the makefile, you can change the compiler command in Build Settings then rebuild.

Here are the GCC preprocessor options. You'll have to google for other compilers.
I have used Microsoft cl as a front end preprocessor but don't remember the details.
https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

Edit: forgot that -o is a general option for GCC

[Updated on: Tue, 27 September 2016 09:34]

Report message to a moderator

Re: How to generate one output file including all include files and the source file [message #1822847 is a reply to message #1744368] Sun, 15 March 2020 15:11 Go to previous message
Hard Breaker is currently offline Hard BreakerFriend
Messages: 1
Registered: March 2020
Junior Member
gcc -save-temps ...

saves the intermediate files separately (*.i are the preprocessor outputs).
Previous Topic:Set working directory in CDT stand-alone debugger - how?
Next Topic:Print array in Debugger console
Goto Forum:
  


Current Time: Fri Apr 26 12:11:24 GMT 2024

Powered by FUDForum. Page generated in 0.03646 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top