10.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
8.130 --min_array_alignment=opt
10.4 __alignof__
Non-Confidential PDF file icon PDF version ARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.