| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.TH gnu::aligned 3attr 2025-06-28 "Linux man-pages 6.18" |
| 6 |
.SH NAME |
| 7 |
gnu::aligned \- set alignment of an object |
| 8 |
.SH SYNOPSIS |
| 9 |
.nf |
| 10 |
.BI [[gnu::aligned( alignment )]] |
| 11 |
.B [[gnu::aligned]] |
| 12 |
.fi |
| 13 |
.SH DESCRIPTION |
| 14 |
This attribute can be applied to a type or a variable, |
| 15 |
and sets its |
| 16 |
.I alignment |
| 17 |
in bytes. |
| 18 |
.P |
| 19 |
If the |
| 20 |
.I alignment |
| 21 |
is not specified, |
| 22 |
the maximum alignment is used. |
| 23 |
This is equivalent to |
| 24 |
.P |
| 25 |
.in +4n |
| 26 |
.EX |
| 27 |
[[gnu::aligned(alignof(max_align_t))]] |
| 28 |
.EE |
| 29 |
.in |
| 30 |
.SH VERSIONS |
| 31 |
.TP |
| 32 |
.BI __attribute__((aligned( alignment ))) |
| 33 |
.TP |
| 34 |
.BI __declspec(align( alignment )) |
| 35 |
.P |
| 36 |
C11 provides the |
| 37 |
.BR _Alignas () |
| 38 |
type specifier, |
| 39 |
which has similar semantics. |
| 40 |
.SH STANDARDS |
| 41 |
GNU. |
| 42 |
.SH HISTORY |
| 43 |
gcc, |
| 44 |
g++, |
| 45 |
clang 11, |
| 46 |
clang++ 2.8.0. |
| 47 |
.SH CAVEATS |
| 48 |
This attribute can increase the natural alignment of a type, |
| 49 |
but it can't decrease it. |
| 50 |
.P |
| 51 |
The linker may limit the maximum alignment that can be applied. |