Why C++ compiles slowly

bearophile bearophileHUGS at lycos.com
Wed Aug 18 19:00:23 PDT 2010


Walter Bright:

> http://www.drdobbs.com/blog/archives/2010/08/c_compilation_s.html
> I'll be doing a followup on why D compiles fast.

Thank you, the article is nice and I didn't know most of the things it contains.


>the compiler is doomed to uselessly reprocess them when one file is #include'd multiple times, even if it is protected by #ifndef pairs. (Kenneth Boyd tells me that upon careful reading the Standard may allow a compiler to skip reprocessing #include's protected by #ifndef pairs. I don't know which compilers, if any, take advantage of this.)<

Probably the latest GCC versions are able to do that.
And then there is #pragma once too:
http://en.wikipedia.org/wiki/Pragma_once


>Just #include'ing the Standard results, on Ubuntu, in 74 files being read of 37,687 lines (not including any lines from multiple #include's of the same file).<

As benchmark on this Clang (the C/C++ compiler based on LLVM) uses a small program (~7500 lines of Object-C) that includes Cocoa/Cocoa.h, that is quite large:
http://clang.llvm.org/performance.html

Bye,
bearophile


More information about the Digitalmars-d mailing list