From: "Jan Beulich" Subject: [PATCH] change BUILD_BUG_ON() Date: Thu, 11 Dec 2008 10:42:22 +0000 Message-ID: <4940FC9E.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org As was noticed on the Linux side, using an array here isn't appropriate if the condition is not a compile time constant - gcc allows such arrays, and hence the intended effect of producing a compiler error is not achieved in that case. Bit field widths do not know similar language extensions, and hence always produce a compiler error. Signed-off-by: Jan Beulich --- 2008-11-20.orig/xen/include/xen/lib.h 2007-09-10 09:59:38.0000000= 00 +0200 +++ 2008-11-20/xen/include/xen/lib.h 2008-12-11 09:54:51.000000000 = +0100 @@ -16,7 +16,7 @@ void __warn(char *file, int line); #define WARN_ON(p) do { if (p) WARN(); } while (0) =20 /* Force a compilation error if condition is true */ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])= ) +#define BUILD_BUG_ON(condition) ((void)sizeof(struct { int:-!!(condition);= })) =20 #ifndef assert_failed #define assert_failed(p) \