alignof
and alignas
¶The alignasof
module arranges for alignas
and alignof
to be more like standard C.
Portability problems fixed by Gnulib:
<stdalign.h>
must be included before
using alignas
or alignof
.
See stdalign.h.
Portability problems not fixed by Gnulib:
alignas
is implementation
dependent, and implementations need not support alignments greater
than alignof (max_align_t)
.
alignas
.
To test this, use the alignasof
module
along with the #if
conditional
(defined alignas || defined __alignas_is_defined
|| 202311 <= __STDC_VERSION__ || 201103 <= __cplusplus)
.
Platforms where alignas
does not work include:
IBM XL C for AIX V16.1.
alignas
must be an integer
constant like ‘8’, instead of an integer constant expression
like ‘4 + 4’ that evaluates to 8:
GCC 4.9.
alignas
and alignof
are macros.