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

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


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.


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