Merge C++ files into a single source file

后端 未结 7 1623
慢半拍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:19

    If you choose to send an individual file rather than a compressed archive, such as a tarball or a zip file, there are probably a few things you should consider.

    First, concatenate the files together as Thomas Matthews already mentioned. With a few changes, you can typically compile the one file. Remove the non-existent #include statements, such as the headers that have now been included.

    You will also have to concatenate these files in their respective dependency order. That is, if a.cpp needs a class declared in b.hpp, then you will most likely need to concatenate in the order Thomas Matthews listed.

    That being said, I think the best way to share code is via a public repository, such as GitHub.com or compressed archive.

提交回复
热议问题