This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Pre-compiled headers


On Wed, Jan 12, 2000 at 10:36:19AM -0800, Per Bothner wrote:
> I vaguely remember that RMS's partially implemented design used
> a third idea:
> 
> #3 Only scan certain definitions if they are needed in the actual
> program.  I don't remember how this was done.  However, we could
> do something like spit the header file into section, one for
> echo declaration/definition (macro, extern, class, ...), and for
> each section specify the names it provides definitions for.
> Then lazily scan those sections when needed.

I like this idea.  Particularly with C++ where there may be scads of
class definitions you don't need.  The trouble is that at precompile
time you need to do enough parsing work to find out what the name is,
and macros defined at compile time may change that.  viz:

#define printf std_printf
#include <stdio.h>

[That's a bad example - I think it's undefined behavior.  But you get
the idea.]

Finally, a hybrid of #1 and #2:
> 
> #2a:  Instead of just tokenizing each header file, we store
> a pre-compiled version that actually contains tree nodes
> in the binary format of the host system.  For example,
> the 'struct pair' would contain a struct tree_type in the
> actual pre-compiled file.

I'd rather not do this for two reasons: first, it is likely to
produce huge files; second, it is likely to have nasty portability
problems.  (nasty == works most of the time but breaks in hard-to-
reproduce corner cases).

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]