Next: , Previous: Type Attributes, Up: C Extensions


5.35 Specifying Attributes of Labels and Statements

The keyword __attribute__ allows you to specify special attributes of labels and statements.

Some attributes are currently defined generically for variables. Other attributes are defined for variables on particular target systems. Other attributes are available for functions (see Function Attributes), types (see Type Attributes) and variables (see Variable Attributes).

You may also specify attributes with `__' preceding and following each keyword. This allows you to use them in header files without being concerned about a possible macro of the same name. For example, you may use __aligned__ instead of aligned.

See Attribute Syntax, for details of the exact syntax for using attributes.

aligned (alignment)
This attribute specifies a minimum alignment for the label, measured in bytes. For example, the declaration:
            some_label: __attribute__((aligned(16)))
     

requests the compiler to align the label, inserting nops as necessary, to a 16-byte boundary.

The alignment is only a request. The compiler will usually be able to honour it but sometimes the label will be eliminated by the compiler, in which case its alignment will be eliminated too.

When applied to loops, the aligned attribute causes the loop to be aligned.

unused
When attached to a label this attribute means that the label might not be used. GCC will not produce a warning for the label, even if the label doesn't seem to be referenced. This feature is intended for code generated by programs which contains labels that may be unused but which is compiled with -Wall. It would not normally be appropriate to use in it human-written code, though it could be useful in cases where the code that jumps to the label is contained within an #ifdef conditional.

This attribute can only be applied to labels, not statements, because there is no warning if a statement is removed.