This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: compile time using 2.96
- From: Eljay Love-Jensen <eljay at adobe dot com>
- To: bob at brasko dot net, gcc-help at gcc dot gnu dot org
- Date: Thu, 06 Nov 2003 20:08:05 -0600
- Subject: RE: compile time using 2.96
Hi Bob,
Some other techniques one can employ to reduce compile times:
+ meticulously include only the header files needed for the compilation unit
+ consider making "header header" files (aka header forwarding files) that do forward declaring of symbols (and a few other things, such as enums) -- and use these "header header files" when possible
+ never rely on a header file including a header file that is needed for a compilation unit -- make sure that header file is included explicitly
+ have good makefiles
+ use GCC to produce dependency files for the makefiles
+ consider splitting out rapidly changing code into its own source file, and only after it has gelled move it into its final source file location
+ read the book "Large-Scale C++ Software Design" by John S. Lakos
+ read the book "Debugging the Development Process" by Steve Maguire
+ read the book "Writing Solid Code" by Steve Maguire
+ read the book "Code Complete" by Steve C. McConnell
In my experience, too often either far too many header files are included in a compilation unit, or worse, ALL header files are included via an all-encompassing header file (ala WIN.H). NOTE: there is another school of thought that is diametrically opposed to this view. Obviously, I am an advocate of the position I've expressed, I'm in utter disagreement with the <WIN.H> mindset.
Poor makefiles can have two detrimental effects: 1) they can be unreliable because they don't build enough, 2) they can be annoying because they build too much (and thus, waste CPU cycles needlessly). Worse, you can have both #1 and #2 in the same makefile. Yuck!
Having unnecessary include files specified in a compilation unit causes unnecessary rebuilds (and thus, wastes time). Even with well crafted makefiles.
HTH,
--Eljay