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:

  • gcc
  • g++
  • clang 11
  • clang++ 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