Supposing I have multiple very long (large number of code lines) cpp file (one major including the others, which, it turn, include some), and given that (for a specific purpose) I would need only a small portions of the files (functions spread over multiple files), I wonder what would be the way to decrease the amount of time needed for compiling process.
Would compile time decrease if I just comment the unnecesarry code from each file? Or, is it better to extract the necessary part and to compile it separately? How would these two approaches differ?
Also, the header file inclusion might affect the compilation time, I guess (major cpp file includes other .cpp files, not a .h convention). So, is packing everything in one file more efficient in terms of compilation time? Perhaps including .h files is more efficient than including .cpp files?
Thanks
So you compile all the cpp. Then you link the object code to make the executable.
If you modify just one cpp, you recompile only that file and link all again.
Because you avoid recompiling all the project over and over again, you gain some time.
Now, about distributing your source code and minimize the compile time for the client. I really don't know.
You could kill everything that you not use, but I'm not sure if the extra work is justified.