Search code examples
c++macrosheader-filescompiler-specific

'Compiling' source files consisting of headers and cpp files into one huge cpp file


How can I get the compiler, or some other tool to spit out one huge source file with the headers included into their respective *.cpp files and then shove all those into one big *.cpp source file?

I have millions of lines of code and lots of mingled macros and protected includes and what not. To manually undertake this would take longer than translating it into machine code in my head.

P.S. The season for doing this is trivial, don't worry, I know this isn't practical at all.


Solution

  • Use the -E option in the gcc compiler. Read more at: https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html