gnu::aligned(3attr) gnu::aligned(3attr)

gnu::aligned - set alignment of an object

[[gnu::aligned(alignment)]]
[[gnu::aligned]]

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))]]

__attribute__((aligned(alignment)))
__declspec(align(alignment))

C11 provides the _Alignas() type specifier, which has similar semantics.

GNU.

gcc, g++, clang 11, clang++ 2.8.0.

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.

2025-06-28 Linux man-pages 6.15