4.1.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

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential