This is the mail archive of the 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]
Other format: [Raw text]

Re: #import, #pragma once yadda yadda mumble grumble

Neil Booth <> writes:

> Geoff Keating wrote:-
> > - Make #import work with PCH.  Despite rumors to the contrary, it still
> >   doesn't; there's just no code to save or restore the required data.  Apple
> >   has an implementation (that I wrote) that uses MD5 checksums, which seems
> >   to work well enough for us.  The only annoying feature is that when you
> >   create a PCH, even if you don't use #import, you must checksum every
> >   header file, because the PCH might have
> > 
> > #include "foo.h"
> > 
> >   and the main file might have
> > 
> > #import "foo.h"
> > 
> >   and you need to know that you've seen it already.  Of course, when
> >   you use the PCH, you don't have to look at the checksums unless
> >   someone has used #import, but you do have to have them available.
> This sounds very expensive and unfair on people who don't use #import -

It's actually pretty cheap---it doesn't even make it into the top 10
items in the profile of GCC building a PCH.  Header files just aren't
that big.

I think if that is the main objection, I should produce a patch and we
can see just how expensive it is.

> having to pay for a feature that others might use.  I'd suggest instead
> just keeping the len/mtime data from the stat() call, which is free since
> we've got this anyway, and falling back to a byte-by-byte comparison.
> This is essentially free for people who don't use #import, and should
> be cheaper even for those who do, since you only have to do a memcmp
> (cheaper than a checksum)

That's not always true.  Sometimes the slow part is the memory (or
filesystem) bandwidth, and using checksums halves the bandwidth

> if it's very likely you're import-ing an already
> included file (or include-ing an already imported one).  Its other advantage
> is that it's already implemented - it's what I currently do to handle
> the non-PCH case.  It does require the PCH'd headers to be accessible,
> but I don't think that's a big deal. 

You might want to consider how this would work with a distributed
build.  How do you make the headers "accessible"?  How do you name
them so that you can find them again?

- Geoffrey Keating <>

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