| Inquiring on Alignment of Types or Variables

Previous | GNU C Language Extensions | Next

The keyword `__alignof__` allows you to inquire about how an object is aligned, or the minimum alignment usually required by a type. Its syntax is just like `sizeof`.
In TIGCC, `__alignof__ (anything)` is always 2, except for `char` variables.
If the operand of `__alignof__` is an lvalue rather than a type, its value is the required alignment for its type, taking into account any minimum alignment specified with GCC's `aligned` attribute. For example, after this declaration:

    struct foo { int x; char y; } foo1;

the value of `__alignof__ (foo1.y)` is 1, even though its actual alignment is 2, the same as `__alignof__ (int)`.
It is an error to ask for the alignment of an incomplete type.