This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib: Start moving switch handling to front ends
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Nicola Pero <nicola at brainstorm dot co dot uk>
- Cc: Stan Shebs <shebs at apple dot com>, Devang Patel <dpatel at apple dot com>,Neil Booth <neil at daikokuya dot co dot uk>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 9 Aug 2002 02:12:23 -0700
- Subject: Re: cpplib: Start moving switch handling to front ends
- References: <3D52BF0C.5060101@apple.com> <Pine.LNX.4.21.0208090812160.16424-100000@nicola.brainstorm.co.uk>
On Fri, Aug 09, 2002 at 08:37:16AM +0100, Nicola Pero wrote:
> I often wondered if by simply replacing these three statements with a new,
> higher-level statement at the beginning of file, we wouldn't make users
> happy.
>
> Something like (pardon the roughness of my example, details can be fixed,
> maybe a #pragma or whatever preprocessor magic, I'm just sketching an
> idea)
>
> #header-name Foundation/NSObject.h
>
> only one '#header-name' would be allowed in the file, and it must be the
> first non-comment code in the file; when encountering this, the
> preprocessor would behave as if the three statements include-protection
> triad had been found - that is something like
>
> #ifndef _INCLUDE_NAME_Foundation/NSObject.h_H_
> #define _INCLUDE_NAME_Foundation/NSObject.h_H_
>
> at the beginning, and
>
> #endif /* _INCLUDE_NAME_Foundation/NSObject.h_H_
>
> at the end of the file (the name of the preprocessor #define is built from
> the provided #header-name).
This is an interesting idea. It avoids the inode problem, since the
magic cookie is part of the file contents. I'd suggest that the right
syntax is to give #pragma once an optional argument; then we need only
explain to users why this argument should be used. The cookie should
be an identifier, for ease of parsing; you should be able to recycle
most of the existing include-guard code.
If you write the patch, and you can get buy-in from the ObjC community
to use this instead of #import, I'd be willing to consider it for FSF GCC.
zw