Re: [PATCH] debug: fix BUILD_BUG_ON() for non-constant expressions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Rusty Russell
Date: Sunday, August 17, 2008 - 6:09 pm

On Monday 18 August 2008 03:33:19 Ingo Molnar wrote:

Hey, I thought I was the "undisputed ruler of Ugly-land".

How about this instead:

#define BUILD_BUG_ON(condition)						\
do {									\
	static struct { char arr[1 - 2*!!(condition)]; } x __maybe_unused;	\
} while(0)

Cheers,
Rusty.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] BUILD_BUG_ON sucks, Alexey Dobriyan, (Sat Aug 16, 3:09 am)
Re: [PATCH] BUILD_BUG_ON sucks, Rusty Russell, (Sat Aug 16, 3:55 am)
Re: [PATCH] BUILD_BUG_ON sucks, Andrew Morton, (Sat Aug 16, 10:46 am)
Re: [PATCH] BUILD_BUG_ON sucks, Linus Torvalds, (Sat Aug 16, 1:07 pm)
Re: [PATCH] BUILD_BUG_ON sucks, Theodore Tso, (Sun Aug 17, 5:19 am)
Re: [PATCH] BUILD_BUG_ON sucks, Andrew Morton, (Sun Aug 17, 9:33 am)
Re: [PATCH] debug: fix BUILD_BUG_ON() for non-constant exp ..., Rusty Russell, (Sun Aug 17, 6:09 pm)