gnu::aligned(3attr)

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.

Standards

GNU.

History

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

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.