__struct_group(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

__struct_group β€” makes you a mirrored named struct and an anonymous one, bestie ✨ (the page spells it "anonyomous" and honestly? iconic. we're keeping the vibe πŸŽ€)


🌸 SYNOPSIS 🌸

__struct_group (TAG , NAME , ATTRS , MEMBERS... );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • TAG β€” the tag name for the named sub-struct. Usually it's just… empty. No thoughts, head empty, tag empty πŸ’…
  • NAME β€” the identifier name of the mirrored sub-struct. This is the one with main character energy πŸ‘‘
  • ATTRS β€” any struct attributes. Also usually empty, we love a low-effort queen 🌈
  • MEMBERS β€” the member declarations for the mirrored structs. This is the actual content, the moment, the reason we're all here 🫢

πŸ”₯ DESCRIPTION πŸ”₯

Okay so here's the tea β˜• β€” this macro builds you an anonymous union of two structs that have identical layout and size: one of them anonymous, one of them named. Literally twins. Same fit, different name tag πŸŽ€

The way this works for you:

  • The anonymous one's members can be used normally, with no sub-struct naming at all β€” just say the member's name and go, no cap πŸ’«
  • The named one lets you reason about the start, the end, and the size of the group of struct members. It's giving "I need to know where this block begins and ends" energy πŸ“

And because that's not enough slay for one macro: the named struct can also be explicitly tagged for layer reuse (C only, bestie β€” C only πŸ‡), and both structs can have struct attributes appended to them. Both. Equally. Periodt πŸ’…βœ¨


⭐ SEE ALSO ⭐

  • Kernel file ./tools/include/uapi/linux/stddef.h β€” go read it, it's the source of truth, iykyk πŸ“–
  • __DECLARE_FLEX_ARRAY(9) β€” its bestie, go say hi πŸ¦‹

ngl this whole thing is one of those "small macro, huge consequences" situations β€” mirrored layout and size is not a suggestion, it's the whole point πŸ’€

mwah, that's the page! brought to you by the fine folks at ./tools/include/uapi/linux, dated October 2026 β€” go forth and mirror your structs, bestie πŸ’œπŸ«Ά

πŸ“¦ where this page comes from