BUILD_BUG_ON(9)
π BUILD_BUG_ON(9) π
okay so bestie, welcome to the Kernel API Manual β this page is literally about making the compiler catch your vibes at build time, not runtime. no cap. β¨
π NAME π
BUILD_BUG_ON β break compile if a condition is true. periodt. π₯
πΈ SYNOPSIS πΈ
BUILD_BUG_ON (condition );
π¦ ARGUMENTS π¦
conditionβ the condition which the compiler should know is false. like, it has to be something the compiler can actually clock at compile time, bestie. π
π DESCRIPTION π
so here's the tea: if you have some code which relies on certain constants being equal, or some other compile-time-evaluated condition, you should use BUILD_BUG_ON to detect if someone changes it. it's giving βguardrail for your constants,β and honestly? iconic. π‘οΈβ¨
like, not me trusting everyone to leave your compile-time assumptions alone β BUILD_BUG_ON is right there to catch it when somebody messes with them. π
π₯ SEE ALSO π₯
also check out the kernel file ./tools/include/linux/build_bug.h, plus BUILD_BUG_ON_MSG(9), BUILD_BUG(9), and static_assert(9). iykyk π«Ά
this page is from ./tools/include/linux, dated October 2026, and it's the BUILD_BUG_ON(9) manual page β mwah ππΈ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms