Jonas Maebe wrote:
On 29 Jul 2010, at 09:47, Adriaan van Os wrote:
If each unit compiles into a separate C++ header file, C++ compilation times will suffer, even if the headers are precompiled. One way I can think of to get around that is a whole-program Pascal compilation mode that translates into one whole-program C++ file that copies only those unit-declarations that are actually used in the program.
Note that this generally causes even larger compilation times compared to separate files (unless you enable the compiler's whole program optimization infrastructure, in which case using separate files will be a bit slower), because all "regular" optimizations (-Ox) are limited to the current compilation unit.
If you put everything in a single compilation unit, then the compiler can optimize more, but if the goal is speeding up compilation then it will probably be counterproductive (possibly unless you only care about compilation speed for -O0 and not at all when using -O1 or higher).
It depends where the compiler is spending its time, generating code or processing declarations, reading unit symbols, etcetera. For GPC on Mac OS X, the bottleneck is absolutely the latter. And (for me) compilations during development (with -O0) are more frequent than release buils (with -O3).
Regards,
Adriaan van Os