Skip to contentSkip to conversation

compiler: fix warning with GCC 4.8.0

PATCH Applied Paolo Bonzini 3 participants 3 messages Mar 27, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 compiler: fix warning with GCC 4.8.0

GCC 4.8.0 introduces a new warning:

block/qcow2-snapshot.c: In function 'qcow2_write_snapshots’:
block/qcow2-snapshot.c:252:18: error: typedef 'qemu_build_bug_on__253'
locally defined but not used [-Werror=unused-local-typedefs]
QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) !=
^
cc1: all warnings being treated as errors

(Caret diagnostics aren't perfect yet with macros... :)) Work around it with __attribute__((unused)).

---
 include/qemu/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/qemu/compiler.h +1 -1
index 2f7998b..6175c24 100644
@@ -33,7 +33,7 @@
 #define cat(x,y) x ## y
 #define cat2(x,y) cat(x,y)
 #define QEMU_BUILD_BUG_ON(x) \
-    typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1];
+    typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused));
 
 #if defined __GNUC__
 # if !QEMU_GNUC_PREREQ(4, 4)
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Paolo Bonzini

GCC 4.8.0 introduces a new warning:

block/qcow2-snapshot.c: In function 'qcow2_write_snapshots’:
block/qcow2-snapshot.c:252:18: error: typedef 'qemu_build_bug_on__253'
locally defined but not used [-Werror=unused-local-typedefs]
QEMU_BUILD_BUG_ON(offsetof(QCowHeader, snapshots_offset) !=
^
cc1: all warnings being treated as errors

Quoted 4 lines

(Caret diagnostics aren't perfect yet with macros... :)) Work around it with __attribute__((unused)).

Thanks, I've just been adding -Wno-unused-local-typedefs locally for a bit.

r~