Skip to contentSkip to conversation

disas: avoid including everything in headers compiled from C++

PATCH In review Paolo Bonzini 2 participants 2 messages Jul 7, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 disas: avoid including everything in headers compiled from C++

disas/arm-a64.cc is careful to include only the bare minimum that it needs---qemu/osdep.h and disas/bfd.h. Unfortunately, disas/bfd.h then includes qemu-common.h, which brings in qemu/option.h and from there we get the kitchen sink.

This causes problems because for example QEMU's atomic macros conflict with C++ atomic types. But really all that bfd.h needs is the fprintf_function typedef, so replace the inclusion of qemu-common.h with qemu/fprintf-fn.h.

---
 include/disas/bfd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/disas/bfd.h +1 -1
index a112e9c..a87b8a1 100644
@@ -9,7 +9,7 @@
 #ifndef DIS_ASM_H
 #define DIS_ASM_H
 
-#include "qemu-common.h"
+#include "qemu/fprintf-fn.h"
 
 typedef void *PTR;
 typedef uint64_t bfd_vma;
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Paolo Bonzini

disas/arm-a64.cc is careful to include only the bare minimum that it needs---qemu/osdep.h and disas/bfd.h. Unfortunately, disas/bfd.h then includes qemu-common.h, which brings in qemu/option.h and from there we get the kitchen sink.

This causes problems because for example QEMU's atomic macros conflict with C++ atomic types. But really all that bfd.h needs is the fprintf_function typedef, so replace the inclusion of qemu-common.h with qemu/fprintf-fn.h.

---
 include/disas/bfd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/disas/bfd.h +0 -0
index a112e9c..a87b8a1 100644

include/disas/bfd.h line 15

Quoted 8 lines
include/disas/bfd.h +1 -1
@@ -9,7 +9,7 @@
 #ifndef DIS_ASM_H
 #define DIS_ASM_H
 
-#include "qemu-common.h"
+#include "qemu/fprintf-fn.h"
 
 typedef void *PTR;
 typedef uint64_t bfd_vma;

I'm sitting on a series that purges qemu-common.h from headers. It makes the same change. I haven't posted it because I want to rebase it onto the "make check-headers" series first. Anyway,