2

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.

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

4 Comments

Is there a way to do this for the vc++ compiler that coems with Visual Studio?
Thanks, I know this is exactly what need. But how could I compile the whole solution like this? The examples only show single files like "/P file.c" but I have a whole solution and I'm terrible at command line stuff.
You can specify multiple files in such a way: cl.exe /P file1.cpp file2.cpp file3.cpp. Unfortunately, I do not know if there's a way to do it with the Visual Studio project.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.