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: cpplib: Start moving switch handling to front ends


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


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