Scroll to navigation

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

NAME

gnu::aligned - set alignment of an object

SYNOPSIS

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

DESCRIPTION

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.

STANDARDS

GNU.

HISTORY

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

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.

2025-06-28 Linux man-pages (unreleased)