rewrite QEMU_BUILD_BUG_ON
authorDong Xu Wang <wdongxu@linux.vnet.ibm.com>
Tue, 20 Dec 2011 09:03:47 +0000 (17:03 +0800)
committerKevin Wolf <kwolf@redhat.com>
Thu, 9 Feb 2012 15:17:51 +0000 (16:17 +0100)
On some platforms, __LINE__ will not expand to real number in QEMU_BUILD_BUG_ON,
so if using QEMU_BUILD_BUG_ON twice, compiler will report errors. This patch will
fix it.

BTW, I got error message on RHEL 6.1/gcc 4.4.5.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
compiler.h

index a1c0794947766226733de71de1051aff42d79805..736e77075ae47d9707946f982478e78d764b0fff 100644 (file)
 # define QEMU_PACKED __attribute__((packed))
 #endif
 
+#define cat(x,y) x ## y
+#define cat2(x,y) cat(x,y)
 #define QEMU_BUILD_BUG_ON(x) \
-    typedef char qemu_build_bug_on__##__LINE__[(x)?-1:1];
+    typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1];
 
 #if defined __GNUC__
 # if !QEMU_GNUC_PREREQ(4, 4)