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?
Never include .cpp files.
Splitting up your code into multiple files is always the fastest method.
Commenting out code will almost be equally fast. There will probably be no or insignificant difference.
First you should rarely if ever include a .cpp file. A .cpp file should be added to your IDE or makefile to be compiled, not included. To decrease build time of your project you can create a library to hold the functions that are fairly static (completed, bug tested, not changing) and then add that library to your build process. Then the required functions would linked to your program without the need to compile them.
This has also been answered elsewhere.
And yet more selfish cross-posting (and time wasting!)
Compile time - Dev Shed
Thanks for your answers. I understand your point, but please note that I do not have any inappropriate intentions. Given the time constraint, it was urgent to get proposals, which usually are different. So, in a sense, you could put everything as "selfish" (there are pages on this, not mine), but, again, I'll try to follow the rules every next time.
I hope you understand.