Next:Extensions toenum Type Declarations, Previous:Support foroffsetof, Up:Other Extensions to C Syntax [Contents][Index]
The keyword__alignof__ determines the alignment requirement ofa function, object, or a type, or the minimum alignment usually requiredby a type. Its syntax is just likesizeof and C11_Alignof.
For example, if the target machine requires adouble value to bealigned on an 8-byte boundary, then__alignof__ (double) is 8.This is true on many RISC machines. On more traditional machinedesigns,__alignof__ (double) is 4 or even 2.
Some machines never actually require alignment; they allow references to anydata type even at an odd address. For these machines,__alignof__reports the smallest alignment that GCC gives the data type, usually asmandated by the target ABI.
If the operand of__alignof__ is an lvalue rather than a type,its value is the required alignment for its type, taking into accountany minimum alignment specified by attributealigned(seeCommon Variable Attributes). For example, after thisdeclaration:
struct foo { int x; char y; } foo1;the value of__alignof__ (foo1.y) is 1, even though its actualalignment is probably 2 or 4, the same as__alignof__ (int).It is an error to ask for the alignment of an incomplete type otherthanvoid.
If the operand of the__alignof__ expression is a function,the expression evaluates to the alignment of the function which maybe specified by attributealigned (seeCommon Function Attributes).
Next:Extensions toenum Type Declarations, Previous:Support foroffsetof, Up:Other Extensions to C Syntax [Contents][Index]