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: Neil Booth <neil at daikokuya dot co dot uk>
- To: Geoff Keating <geoffk at geoffk dot org>
- 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: Mon, 4 Aug 2003 09:48:45 +0100
- 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>
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 -
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) 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.
I'm open to your readdir() thing if it's a win in situations not
restricted to Apple like you claim it is, and the search path abstraction
if it's essentially costless to non-users.
Thanks,
Neil.