Skip to contentSkip to conversation

disas: Fix ATTRIBUTE_UNUSED define clash with ALSA headers

PATCH In review Peter Maydell 2 participants 3 messages Jul 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 disas: Fix ATTRIBUTE_UNUSED define clash with ALSA headers

disas/bfd.h defines ATTRIBUTE_UNUSED, but unfortunately the ALSA system headers also define this macro, which means that you can get a compilation failure if building with ALSA and any files happen to include the alsa headers before bfd.h rather than the other way around.

This is unfortunate namespace pollution by the ALSA headers but we can work around it. Add an #ifndef guard to bfd.h and remove the unnecessary extra definition in disas/arm.c to fix this.

---
 disas/arm.c         | 1 -
 include/disas/bfd.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
disas/arm.c +0 -1
index 32f8ca9..426270f 100644
@@ -24,7 +24,6 @@
 
 #include "qemu/osdep.h"
 #include "disas/bfd.h"
-#define ATTRIBUTE_UNUSED __attribute__((unused))
 #define ISSPACE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
 
 #define ARM_EXT_V1	 0
include/disas/bfd.h +2 -0
index 231e5fb..8a3488c 100644
@@ -477,7 +477,9 @@ int generic_symbol_at_address(bfd_vma, struct disassemble_info *);
   (INFO).disassembler_options = NULL, \
   (INFO).insn_info_valid = 0
 
+#ifndef ATTRIBUTE_UNUSED
 #define ATTRIBUTE_UNUSED __attribute__((unused))
+#endif
 
 /* from libbfd */
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Peter Maydell

disas/bfd.h defines ATTRIBUTE_UNUSED, but unfortunately the ALSA system headers also define this macro, which means that you can get a compilation failure if building with ALSA and any files happen to include the alsa headers before bfd.h rather than the other way around.

This is unfortunate namespace pollution by the ALSA headers but we can work around it. Add an #ifndef guard to bfd.h and remove the unnecessary extra definition in disas/arm.c to fix this.

Quoted 6 lines
---
 disas/arm.c         | 1 -
 include/disas/bfd.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
#2 lore raw
Quoted 11 lines · Stefan Hajnoczi
Quoted 10 lines · Peter Maydell

disas/bfd.h defines ATTRIBUTE_UNUSED, but unfortunately the ALSA system headers also define this macro, which means that you can get a compilation failure if building with ALSA and any files happen to include the alsa headers before bfd.h rather than the other way around.

This is unfortunate namespace pollution by the ALSA headers but we can work around it. Add an #ifndef guard to bfd.h and remove the unnecessary extra definition in disas/arm.c to fix this.

Quoted 8 lines
Quoted 6 lines
---
 disas/arm.c         | 1 -
 include/disas/bfd.h | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

Thanks; applied to master as a buildfix.

-- PMM