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]

Re: Attribute questions


On Thu, 28 Jun 2001, Mark Mitchell wrote:

> 2.Do people really use "prefix attributes"?  They are undocumented,
>   as far as I can tell.  (This is the bit where you fix attributes
>   in with the decl-specifier-seq in a declaration, like this:
> 
>     void __attribute__ ((pure)) f();
> 
>   Very ugly.  I expect we daren't remove these, right?

They are documented.  See "Attribute Syntax" in the manual.  As someone
noted, they are necessary to put attributes on a function definition.  I
also think they are the cleaner syntax, since the only way of attaching
attributes to a nested declarator (something the C++ front end implements
better than the C one, though there are still problems) is as prefix
attributes, and mixing several different positions is a mess.  Where the
attributes are like storage class specifiers - such as "section" - putting
them as prefix attributes is logical since storage class specifiers go
there.

(See http://bugs.debian.org/12253 for the bug report that prompted
documenting this mess.)

I don't now intend to make the possible changes to semantics of postfix
attributes documented in that section (making them apply to declarators
rather than declarations in some cases, allowing them on function
definitions, allowing them before asm specifications), though the warnings
there about the semantics are probably still useful, and I do intend to
fix the problems with attributes on nested declarators (including e.g.  
making format attributes work for function pointers, using the function
type not the function name).

> 3. The manual contains anti-#pragma rhetoric.  As far as I can tell,
>    that rhetoric isn't really longer valid.  The manual says that
>    #pragma can't be generated from a macro, but in C99, _Pragma
>    solves this problem.  The manual also says that you can't have
>    any idea what another compiler will do with the same #pragma.
>    I don't think you can have a whole lot of ideas about what
>    another compiler will do with __attribute__ ((pure)) either.
>    The only safe way to use either if as the output of macros that
>    are conditionalized on the compiler that you are using.

This is the rhetoric I converted into the past tense?  "At the time
@code{__attribute__} was designed, there were ...", "It was basically a
mistake ...", ...?

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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