alignas, __alignas_is_defined

Updated: April 19, 2023

Specify the alignment of an object

Synopsis:

#include <stdalign.h>

#define __alignas_is_defined	1

#ifndef __cplusplus
#define alignas	_Alignas;
#endif /* __cplusplus */

Description:

The alignas macro expands to the C11 _Alignas keyword, which specifies the alignment requirements of the object being declared. The _Alignas keyword has the following forms:

_Alignas( expression )
_Alignas( type )

where expression is an integer constant expression whose value is 0 or a valid alignment, and type is any type name. The object's alignment is the value of expression (if nonzero) or the value of alignof for the given type, unless this would weaken the alignment that the object would normally have.

You can use alignas when you define objects that aren't bit fields and that don't have the register storage class. You don't need to use it when declaring objects, but if you do, the alignment must be the same as in the definition of the object. You can't use alignas when declaring function parameters or in a typedef.

The value of __alignas_is_defined is 1.

Classification:

C11