#import, #pragma once yadda yadda mumble grumble
Geoff Keating
geoffk@geoffk.org
Mon Aug 4 19:21:00 GMT 2003
Neil Booth <neil@daikokuya.co.uk> 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
requirement.
> 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 <geoffk@geoffk.org>
More information about the Gcc
mailing list