[lkml]   [2005]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[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.


Index: linux/include/linux/kernel.h
--- linux.orig/include/linux/kernel.h
+++ linux/include/linux/kernel.h
@@ -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)]))

extern int randomize_va_space;
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2005-09-10 14:07    [W:0.024 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site