gnu::aligned3attr
Set alignment of an object
Usage
[[gnu::aligned(alignment)]] [[gnu::aligned]]
Overview
This attribute can be applied to a type or a variable, and sets its alignment in bytes.
If the alignment is not specified, the maximum alignment is used. This is equivalent to
[[gnu::aligned(alignof(max_align_t))]]
Versions
__attribute__((aligned(alignment)))
__declspec(align(alignment))
C11 provides the _Alignas() type specifier, which has similar semantics.
Caveats
This attribute can increase the natural alignment of a type, but it can't decrease it.
The linker may limit the maximum alignment that can be applied.