steveyang
steveyang

Reputation: 9298

How to output the intermediate file after gcc has included all header files for a C program?

In a typical C program, I break down it into several components:

// main.c
#include 'part-a.h'
#include 'part-b.h'

main () {
// ...
}

// part-a.h
#include 'part-c.h'
// ...

I want to export the whole project as one file including every dependencies recursively (excluding standard libraries), how could I do that with gcc?

Upvotes: 0

Views: 727

Answers (1)

chill
chill

Reputation: 16888

gcc -E plus all the other option you normally use to compile, without -c. This will produce preprocessor output. It's the best you can get, AFAIK there's no way to only expand #include directives. But you can use some preprocessor library (GCC and Boost have ones) to write your own tool.

http://www.boost.org/doc/libs/1_54_0/libs/wave/

Upvotes: 4

Related Questions