I have a c++ project with multiple source files and multiple header files. I want to submit my project for a programming contest which requires a single source file. Is there an automated way of collapsing all the files into single .cpp file?
For example if I had a.cpp, a.h, b.cpp, b.h etc., I want to get a main.cpp which will compile and run successfully. If I did this manually, could I simply merge the header files and append the source files to each other? Are there gotchas with externs, include dependencies and forward declarations?
#include "a.cpp" #include "b.cpp" ...of your project (no .h files!). Then compile this single .cpp file with the /E option. The result (stdout) is a single .cpp file, which contains the whole project. That's not convenient and the output is not really a beauty. However, it works. - mdew