about function attributes for functions returning a pointer

Ian Lance Taylor iant@google.com
Thu Feb 10 18:45:00 GMT 2011


Uwe Kleine-König <u.kleine-koenig@pengutronix.de> writes:

>> I think the differences you are seeing are because some attributes can
>> apply to types and some can only apply to declarations.  Moving the
>> location of the __attribute__ affects which type it applies to.  In
>> particular __attribute__ ((unused)) may be used with a type, but
>> __attribute__ ((section (...))) may only be used with a declaration.
>
> As far as I got it both section() and unused are variable/function
> attributes and not type attributes.  So I think this explanation doesn't
> match, does it?

The unused attribute can be used on a type.

typedef int I1 __attribute__ ((unused));
typedef int I2 __attribute__ ((section (".sec")));

foo.c:2: error: section attribute not allowed for ‘I2’

There is no error for I1.

What the unused attribute means for a type I decline to speculate.  But
it is accepted where type attributes are accepted.  Perhaps this is a
bug.  I'm really not sure.

Ian



More information about the Gcc-help mailing list