
On Fri, 20 Mar 2009 10:20:21 +0100, Yang Zhang
Is there any advice on taming (1) the generated code size and/or (2) the build times* which result from using a header-mostly library like Boost? A large C++ project consists of many translation units (.o files) which are generated from source files that include many of the same Boost headers over and over again. (2) can be ameliorated with a distributed build process, but the more general issue here is that of consumption of compute resources, be it time or machines.
I can't say much about (1), but for (2) I can share some experience. Most of the compile time comes from recompiling the same headers over and over again, so reducing the number of header files parsed for each translation unit pays dividends. We use forward declarations in header files extensively, and only include header files in header files where ABSOLUTELY necessary. This sometimes means that we use pointers and shared_ptr<>s for holding stuff that is strictly speaking an accumulated class member, depending how much code includes the class in question. A forward declared "pimpl" can also help a lot. HTH! -- Joachim Pihl Senior R&D Engineer Nevion Tel: +47 33 48 94 66 Fax: +47 33 48 99 98 Mobile: +47 91 33 98 91 jpihl@nevion.com www.nevion.com ----------------------------------- The Global Video Transport Leader -----------------------------------