Make BUILD_BUG_ON fail at compile time.
PATCH 1/2 Make BUILD_BUG_ON fail at compile time.
Make BUILD_BUG_ON fail at compile time.
Force a compiler error instead of a link error, because they are easier to track down. Idea stolen from code by Jan Beulich.
include/linux/kernel.h +2 -2
@@ -307,8 +307,8 @@ struct sysinfo {char _f[20 -2 *sizeof (long )-sizeof (int )];/* Padding: libc5 uses this.. */ }; -extern void BUILD_BUG (void ); -#define BUILD_BUG_ON (condition) do { if (condition) BUILD_BUG(); } while(0) +/* Force a compilation error if condition is false */ +#define BUILD_BUG_ON (condition) ((void)sizeof(char[1 - 2*!!(condition)]))#ifdef CONFIG_SYSCTL extern int randomize_va_space;
Quoted 6 lines · Andi Kleen
Make
BUILD_BUG_ONfail at compile time.Force a compiler error instead of a link error, because they are easier to track down. Idea stolen from code by Jan Beulich.
reiser4 seems to have a duplicate version of this, Hans, can you switch over to the common one once this is in?
Quoted 8 lines · Christoph Hellwig
Quoted 5 lines · Andi Kleen
Make
BUILD_BUG_ONfail at compile time.Force a compiler error instead of a link error, because they are easier to track down. Idea stolen from code by Jan Beulich.
Quoted 11 lines
Quoted 3 lines
reiser4 seems to have a duplicate version of this, Hans, can you switch over to the common one once this is in?
Yes we can.