Merge C++ files into a single source file

后端 未结 7 1615
慢半拍i
慢半拍i 2020-12-10 01:27

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 the

相关标签:
7条回答
  • 2020-12-10 02:20

    In general, you cannot do this. Whilst you can happily paste the contents of header files to the locations of the corresponding #includes, you cannot, in general, simply concatenate source files. For starters, you may end up with naming clashes between things with file scope. And given that you will have copy-pasted header files (with class definitions, etc.) into each source file, you'll end up with classes defined multiple times.

    There are much better solutions. As has been mentioned, why not simply zip up your entire project directory (after you've cleaned out auto-generated object files, etc.)? And if you really must have a single source file, then just write a single source file!

    0 讨论(0)
提交回复
热议问题