This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
FSF GCC, #import and #pragma once
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: gcc at gcc dot gnu dot org
- Cc: Stan Shebs <shebs at apple dot com>, Geoffrey Keating <gkeating at apple dot com>,Nicola Pero <nicola at brainstorm dot co dot uk>,Zack Weinberg <zack at codesourcery dot com>
- Date: Tue, 4 Mar 2003 21:09:08 +0000
- Subject: 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.