Re: about function attributes for functions returning a pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 10, 2011 at 07:44:29AM -0800, Ian Lance Taylor wrote:
> Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx> 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.
Ah, found something about unused being a type attribute.  My gcc docs (i.e.
gcc-4.3.info) say:

`unused'
     When attached to a type (including a `union' or a `struct'), this
     attribute means that variables of that type are meant to appear
     possibly unused.  GCC will not produce a warning for any variables
     of that type, even if the variable appears to do nothing.  This is
     often the case with lock or thread classes, which are usually
     defined and then not referenced, but contain constructors and
     destructors that have nontrivial bookkeeping functions.

This doesn't help me on my original problem though.

Best regards
Uwe


-- 
Pengutronix e.K.                           | Uwe Kleine-KÃnig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux