Is there a way for multiple .cpp files to act as a single file?
Yes. This is the definition of #include
. When you #include
file, you create a text replacement for the included file instead of the #include
directive. Thus, several included files act together to form one translation unit.
In your case, we interrupt the file for several bits. Do it for sure - do not add or diminish lines of text. Do not add title controls or anything else. You can split your files in almost any convenient place. Limitations: a break must not occur inside a comment or inside a line, and it must appear at the end of a logical line.
Name the newly created partial files according to some conventions. They are not fully formed translation units, so do not call them *.cpp
. They are not proper header files, so do not name them *.h
. Rather, they are partially complete translation units. Perhaps you could name them *.pcpp
.
As for the base name, select the original file name with a serial number: MyProg01.pcpp
, MyProg02.pcpp
, etc.
Finally, replace the source file with a series of #include
statements:
#include "MyProg01.pcpp" #include "MyProg02.pcpp" #include "MyProg03.pcpp"
source share