| |||
| Home > Compiler-specific Features > Keywords and operators > __ALIGNOF__ | |||
The __ALIGNOF__ keyword returns the alignment
requirement for a specified type, or for the type of a specified
object.
__ALIGNOF__( returns
the alignment requirement for the type type),
or 1 if there is no alignment requirement.type
__ALIGNOF__( returns
the alignment requirement for the type of the lvalue expr),
or 1 if there is no alignment requirement. The lvalue itself is
not evaluated.expr
typedef struct s_foo { int i; short j; } foo;
typedef __packed struct s_bar { int i; short j; } bar;
return __ALIGNOF(struct s_foo); // returns 4
return __ALIGNOF(foo); // returns 4
return __ALIGNOF(bar); // returns 1