[PATCH] linux/bug.h: make BUILD_BUG_ON generate compile-time error

From: Daniel Santos
Date: Mon Jun 04 2012 - 07:36:25 EST


This is a multi-part message in MIME format.This is pretty straight-forward. __compiletime_error is defined in
compiler-gcc4.h with appropriate version checks, so shouldn't break on
older compilers. This makes the difference between getting an error at
link-time and getting one at compile time. Example:

/home/daniel/proj/kernel/grbtest/grbtest2.c:83:2: error: call to
‘__build_bug_on_failed’ declared with attribute error: BUILD_BUG_ON
failed: !__builtin_constant_p(count)

The above points me directly to where I called BUILD_BUG_ON. Note that
I'm moving __build_bug_on_failed out of the global scope, just so it can
be re-declared with different attributes each time.

Daniel