This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Efficient linking
Hi Starling,
I think you should read this book, "Large-Scale C++ Software Design" by Lakos.
And you should also be concerned about having good makefiles, as per this PDF essay "Recursive Make Considered Harmful" by Miller. URL: <http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html>.
My own rules of thumb:
+ Every header file should include ONLY the header files that they need.
+ Every source file should include ONLY the header files that they need.
+ No header/source file should depend upon a needed header file being included by another header file. After all, someone may change a header's included header to a forward declaration (which I also shy away from).
+ Every header file should be "complete", such that they are stand-alone compileable.
+ No (or very few) "uber header files" that includes all header files.
+ No reliance upon PCH to include everything and the kitchen sink. Very bad practice, in my opinion.
+ Use generated dependencies in your makefiles.
+ Use make fragments, which are all make-included into a whole. (Assuming you use GNU make.)
+ No recursive builds. (Presuming the individual builds otherwise have interdependencies.)
These rules mean that you won't "build too much" (waste of time), nor "build too little" (untrustworthy builds, unless done from a clean slate). And you should be able to take advantage of multi CPUs for concurrent builds.
--Eljay