Variable attributes
Beginning of IBM® Extension.
Variable attributes are language extensions provided to facilitate the compilation of programs developed with the GNU C/C++ compilers. These language features allow you to use named attributes to specify special properties of data objects. Variable attributes apply to the declarations of simple variables, aggregates, and member variables of aggregates.
A
variable attribute is specified with the keyword __attribute__ followed
by the attribute name and any additional arguments the attribute name
requires. A variable __attribute__ specification
is included in the declaration of a variable, and can be placed before
or after the declarator. Although there are variations, the syntax
generally takes either of the following forms:
The attribute name can be specified with or without leading and trailing double underscore characters; however, using the double underscore reduces the likelihood of a name conflict with a macro of the same name. For unsupported attribute names, the IBM i compiler issues diagnostics and ignores the attribute specification. Multiple attribute names can be specified in the same attribute specification.
struct A {
int b __attribute__((aligned)); /* typical placement of variable */
/* attribute */
int __attribute__((aligned)) c; /* variable attribute can also be */
/* placed here */
int d, e, f __attribute__((aligned)); /* attribute applies to f only */
int g __attribute__((aligned)), h, i; /* attribute applies to g only */
int __attribute__((aligned)) j, k, l; /* attribute applies to j, k, and l */
};
End of IBM Extension.
