This is the mail archive of the gcc@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]

FSF GCC, #import and #pragma once


I've a suggestion to make that I'm hoping will break the impasse here.

I suggest that, with the following semantics, we undeprecate #import
in GCC:

1) #import A followed by #import B, where A and B are identical
   strings with identical quotes guarantees once-only semantics.
2) #import "A" followed or preceded by #import <A> is undefined
   behaviour.  You may or may not get once-only.
3) Things like #import <time.h> followed by #import <sys/time.h>
   where time.h resolves to the file in sys/time.h is undefined
   behaviour.  You may or may not get once-only.

The big advantage of this, from FSF GCC's point of view, is that
we don't have to worry about aliasing; that becomes the programmer's
problem, and our maintenance burden is removed.  However, we still
guarantee, via 1), the once-only semantics that 95% of users care
about, I imagine.  I hope it also means that GNUStep can continue
to be compatible with Apple to the extent that they need.

I'm open minded on:

o Removing #pragma once.  If we keep it, same guarantees as #import
  based on how the header was included.
o Dropping #import from C, and making it ObjC only.

If this is generally considered a way forward (and I doubt we'll ever
get anything much better), then I'm happy to create a patch.

Thoughts?

Neil.


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