This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: #import, #pragma once yadda yadda mumble grumble
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Neil Booth <neil at daikokuya dot co dot uk>
- Cc: gcc-patches at gcc dot gnu dot org, Mike Stump <mrs at apple dot com>, Nicola Pero <nicola at brainstorm dot co dot uk>, gcc at gcc dot gnu dot org, Stan Shebs <shebs at apple dot com>, Zack Weinberg <zack at codesourcery dot com>, David Ayers <d dot ayers at inode dot at>
- Date: 04 Aug 2003 12:08:56 -0700
- Subject: Re: #import, #pragma once yadda yadda mumble grumble
- References: <20030729222547.GF14334@daikokuya.co.uk><DE889F08-C219-11D7-BF45-0030657EA24A@apple.com><20030803123009.GC26598@daikokuya.co.uk><jmel02xs7j.fsf@desire.geoffk.org><20030804084845.GA11847@daikokuya.co.uk>
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>