qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 1/2] compiler: add ignore_value() macro


From: Felipe Franciosi
Subject: [Qemu-devel] [PATCH 1/2] compiler: add ignore_value() macro
Date: Wed, 21 Sep 2016 16:27:01 +0100

On GCC versions 3.4 and newer, simply using (void) in front of a
function that has been declared with WUR will no longer suppress a
compilation warning. This commit brings the ignore_value() macro from
GNULIB's ignore_value.h, licensed under the terms of LGPLv2+.

See the link below for the original author's comment:
https://lists.nongnu.org/archive/html/qemu-devel/2016-09/msg05148.html

Signed-off-by: Felipe Franciosi <address@hidden>
---
 include/qemu/compiler.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 338d3a6..655d0c7 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -26,6 +26,14 @@
 #define QEMU_WARN_UNUSED_RESULT
 #endif
 
+/* The ignore_value() macro comes from GNULIB's LGPLv2+ ignore-value.h */
+#if QEMU_GNUC_PREREQ(3, 4)
+# define ignore_value(x) \
+         (__extension__ ({ __typeof__ (x) __x = (x); (void) __x; }))
+#else
+# define ignore_value(x) ((void) (x))
+#endif
+
 #if QEMU_GNUC_PREREQ(4, 0)
 #define QEMU_SENTINEL __attribute__((sentinel))
 #else
-- 
1.9.5




reply via email to

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