qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH] QEMU_BUILD_BUG_ON: use __COUNTER__
Date: Tue, 31 Jan 2017 16:43:52 +0200

Some headers use QEMU_BUILD_BUG_ON. This causes a problem
if the C file including that header happens to have
QEMU_BUILD_BUG_ON at the same line number.

Fix using a widely available extension: __COUNTER__.
If unavailable, provide a stub.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 include/qemu/compiler.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index e0fb18b..bad25a9 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -89,8 +89,12 @@
     struct { \
         int:(x) ? -1 : 1; \
     }
+#ifdef __COUNTER__
 #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
-    glue(qemu_build_bug_on__, __LINE__) __attribute__((unused))
+    glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
+#else
+#define QEMU_BUILD_BUG_ON(x)
+#endif
 
 #define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
                                    sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
-- 
MST



reply via email to

[Prev in Thread] Current Thread [Next in Thread]