cpplib: Start moving switch handling to front ends

Zack Weinberg zack@codesourcery.com
Thu Aug 8 00:11:00 GMT 2002


On Thu, Aug 08, 2002 at 07:24:31AM +0100, Neil Booth wrote:
> Zack Weinberg wrote:-
> 
> > No, really.  The semantics of #import (and #pragma once) require that
> > the compiler be able to determine whether two include requests refer
> > to the same file, with 100% accuracy, for _correctness_.  This is
> > impossible without making unportable assumptions about file system
> > semantics, which cpplib does not do.
> 
> We have them at the top of cppinit.c for duplicate directory checking.
> Are you sure there's nothing we can do (granted, it might be a bit
> awkward).  I think expecting the millions of lines of ObjC code to
> suddenly stop using it is a bit much.

It would not be that hard to do the inode/dev check after opening the
file, we call fstat() anyway.  And that'd be a good idea.  (Have to figure
out a way to index the include cache on two different keys, though.)
It's just that, since inode numbers are not universally reliable --
hell, it's not even universally reliable _on Unix_, in the presence of
some file systems, and we are _not_ putting an fstatfs() blacklist in
there -- I don't want to encourage its use.

The other problem with #import is that the semantics are ill-defined
when someone uses both #import and #include to refer to (what turns
out to be) the same file.

> I'm all for banging #pragma once on the head for 3.4 though, so it
> becomes an unknown pragma and treated like any other.

Fine by me.

zw



More information about the Gcc-patches mailing list