gnu::aligned(3attr)
β¨ gnu::aligned β setting the alignment of an object β¨
okay bestie, gather round, because this is one of those little GNU attributes from the 3attr man page collection and it's lowkey iconic π
πΈ NAME πΈ
gnu::aligned β literally just: setting the alignment of an object π
π¦ SYNOPSIS π¦
[[gnu::aligned(alignment)]]
[[gnu::aligned]]
two flavors, take your pick, both slay π
π DESCRIPTION π
so here's the tea β β you can sprinkle this attribute on a type or on a variable, and what it does is set that thing's alignment in bytes. that's it. that's the whole job bestie, and it does it well π
now, if you don't give it an alignment? no stress, it just uses the maximum alignment β¨ and fr fr, that is exactly the same as writing:
[[gnu::aligned(alignof(max_align_t))]]
so yeah, leaving it blank is giving "give me the most alignment you've got" energy π
π VERSIONS π
the ancestor forms, the OG spellings, in case you're on a compiler that didn't get the memo about the cute [[...]] syntax:
__attribute__((aligned(alignment)))__declspec(align(alignment))
and plot twist β C11 rolled up with its own type specifier, _Alignas(), which has similar semantics. so if you're feeling standards-coded, that one's there for you too π«Ά
β STANDARDS β
GNU. yeah. it's built different.
π HISTORY π
a little origin story for the girlies π β the glow-up timeline is:
gccg++clang 11clang++ 2.8.0
not me being dramatic about compiler versions, i simply think it's important to know where the vibes came from π¦
π CAVEATS π
okay listen, this is the part where we put on our serious face for a sec π
- this attribute can increase the natural alignment of a typeβ¦ but it can't decrease it. periodt. it only goes up, never down, no negotiating π ββοΈ
- and the linker may limit the maximum alignment that can be applied β so even if you ask for something absolutely unhinged, the linker might be the one saying "bestie no" π
β οΈ so fr fr β alignment requests are a ceiling-less floor, not a free-for-all. you can go bigger, never smaller, and the linker has veto power π
πΈ SEE ALSO πΈ
(pssst, if the original page had a SEE ALSO section, everything from it lives right here β nothing skipped, no cap π«Ά)
and that's the whole manual page, bestie, we ate and left no crumbs πβ¨ this gem is from Linux man-pages 6.20, dated 2025-06-28 β mwah, go forth and align your objects responsibly ππ¦π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms