DEFINE_RAW_FLEX(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… DEFINE_RAW_FLEX(9) β€” the Kernel API Manual moment πŸŽ€

okay so bestie, we're in the Kernel API Manual rn and this page is literally about DEFINE_RAW_FLEX β€” and no, it's not a dance move, it's a macro. let's get into it ✨


🌸 NAME 🌸

DEFINE_RAW_FLEX β€” defines an on-stack instance of a structure that has a trailing flexible array member, specifically for the case where that member does not have a __counted_by annotation. iykyk 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

DEFINE_RAW_FLEX (type , name , member , count );

like, that's the whole vibe. four things go in, a whole struct comes out πŸ’…


πŸ’– ARGUMENTS πŸ’–

  • type β€” the structure type name, and this includes the struct keyword fr fr, don't forget it.
  • name β€” the name for the variable you're defining. your main character's name, basically πŸ‘‘
  • member β€” the name of the array member.
  • count β€” the number of elements in the array, and heads up: it must be a compile-time constant. no runtime shenanigans bestie, none. 🚫

⭐ DESCRIPTION ⭐

So what it does: it defines a zeroed, on-stack instance of type structure with a trailing flexible array member. zeroed. on-stack. iconic behaviour honestly. ✨

Then you've got your little helper squad for checking sizes at compile time:

  • use __struct_size(name) to get the compile-time size of it afterwards.
  • use __member_size(name->member) to get the compile-time size of the name members.
  • use STACK_FLEX_ARRAY_SIZE(name, member) to get the compile-time number of elements in the array member.

three little besties, all compile-time, all slay. 🧚


πŸ”₯ SEE ALSO πŸ”₯

the kernel file ./include/linux/overflow.h and honestly the whole overflow friend group came through:

check_add_overflow(9), wrapping_add(9), wrapping_assign_add(9), check_sub_overflow(9), wrapping_sub(9), wrapping_assign_sub(9), check_mul_overflow(9), wrapping_mul(9), check_shl_overflow(9), overflows_type(9), range_overflows(9), range_overflows_t(9), range_end_overflows(9), range_end_overflows_t(9), castable_to_type(9), size_mul(9), size_add(9), size_sub(9), array_size(9), array3_size(9), flex_array_size(9), struct_size(9), struct_size_t(9), struct_offset(9), __DEFINE_FLEX(9), _DEFINE_FLEX(9), DEFINE_FLEX(9), STACK_FLEX_ARRAY_SIZE(9), typeof_flex_counter(9), overflows_flex_counter_type(9), __set_flex_counter(9)

like, the whole group chat. go say hi. πŸ’€πŸ’–


ngl that's the entire page. no cap, no filler, nothing hidden. πŸ“

okay so final sign-off: this lil page lives at ./include/linux and it's dated October 2026 β€” yes, from the future, don't ask. periodt. πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from