9.3 __ALIGNOF__

The __ALIGNOF__ keyword returns the alignment requirement for a specified type, or for the type of a specified object.

Syntax

__ALIGNOF__(type)
__ALIGNOF__(expr)
Where:
type
is a type
expr
is an lvalue.

Return value

__ALIGNOF__(type) returns the alignment requirement for the type type, or 1 if there is no alignment requirement.
__ALIGNOF__(expr) 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.

Example

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
Related reference
7.112 --min_array_alignment=opt
9.4 __alignof__
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.