提交 921717a2 编写于 作者: A Andi Kleen 提交者: Linus Torvalds

[PATCH] 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 <jbeulich@novell.com>

If the argument to BUILD_BUG_ON evaluates to non-zero the compiler will do:

	t.c:6: error: size of array `type name' is negative

(surprised that gcc doesn't have an extension for this)
Signed-off-by: N"Andi Kleen" <ak@suse.de>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 0f3d2bd5
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册