table of contents
other versions
- wheezy 3.2.78-1
BUILD_BUG_ON(9) | Driver Basics | BUILD_BUG_ON(9) |
NAME¶
BUILD_BUG_ON - break compile if a condition is true.SYNOPSIS¶
BUILD_BUG_ON(condition);
ARGUMENTS¶
conditionthe condition which the compiler should know
is false.
DESCRIPTION¶
If you have some code which relies on certain constants being equal, or other compile-time-evaluated condition, you should use BUILD_BUG_ON to detect if someone changes it. The implementation uses gcc's reluctance to create a negative array, but gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments to inline functions). So as a fallback we use the optimizer; if it can't prove the condition is false, it will cause a link error on the undefined “__build_bug_on_failed”. This error message can be harder to track down though, hence the two different methods.COPYRIGHT¶
March 2016 | Kernel Hackers Manual 3.2. |