Skip to contentSkip to conversation

vl.c: Fix OpenBSD compilation issue due to namespace collisions

PATCH Superseded Marcel Apfelbaum 2 participants 6 messages Mar 18, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vl.c: Fix OpenBSD compilation issue due to namespace collisions

Machine rewriting added MACHINE macro which is
already in use by other OpenBSD library.
Since qemu/sockets.h exposes the OpenBSD namespace,
the minimalistic approach is to add it as the first QEMU include.

---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -1
index f0fe48b..9f86e68 100644
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "qemu/sockets.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/usb.h"
@@ -103,7 +104,6 @@ int main(int argc, char **argv)
 
 #include "disas/disas.h"
 
-#include "qemu/sockets.h"
 
 #include "slirp/libslirp.h"
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 24 lines · Marcel Apfelbaum

Machine rewriting added MACHINE macro which is
already in use by other OpenBSD library.
Since qemu/sockets.h exposes the OpenBSD namespace,
the minimalistic approach is to add it as the first QEMU include.

---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -0
index f0fe48b..9f86e68 100644
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "qemu/sockets.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/usb.h"

vl.c int main(int argc, char **argv) · line 108

Quoted 6 lines
vl.c +0 -1
@@ -103,7 +104,6 @@ int main(int argc, char **argv)
 
 #include "disas/disas.h"
 
-#include "qemu/sockets.h"
 
 #include "slirp/libslirp.h"

I'm confused; why doesn't this just result in a compiler error in the other direction when we try to #define MACHINE in QEMU and it's already been defined by the BSD headers?

thanks
-- PMM

#3 lore raw
In reply to Marcel Apfelbaum
Quoted 37 lines · Marcel Apfelbaum
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Marcel Apfelbaum

Machine rewriting added MACHINE macro which is
already in use by other OpenBSD library.
Since qemu/sockets.h exposes the OpenBSD namespace,
the minimalistic approach is to add it as the first QEMU include.

---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -0
index f0fe48b..9f86e68 100644
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "qemu/sockets.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/usb.h"
@@ -103,7 +104,6 @@ int main(int argc, char **argv)
 
 #include "disas/disas.h"
 
Quoted 8 lines

vl.c int main(int argc, char **argv) · line 108

Quoted 3 lines
vl.c +0 -1
-#include "qemu/sockets.h"
 
 #include "slirp/libslirp.h"

I'm confused; why doesn't this just result in a compiler error in the other direction when we try to #define MACHINE in QEMU and it's already been defined by the BSD headers?

Quoted 3 lines

Maybe because there is usage of the "MACHINE" define by the BSD library? (on Qemu context, of course! - meaning, it shouldn't even be exposed in the first place!)

I meant "there is *no* usage of the..."

Quoted 9 lines

Thanks,
Marcel

Quoted 3 lines

thanks
-- PMM

#4 lore raw
Quoted 10 lines · Marcel Apfelbaum
Quoted 8 lines · Marcel Apfelbaum
Quoted 4 lines · Peter Maydell

I'm confused; why doesn't this just result in a compiler error in the other direction when we try to #define MACHINE in QEMU and it's already been defined by the BSD headers?

Maybe because there is usage of the "MACHINE" define by the BSD library? (on Qemu context, of course! - meaning, it shouldn't even be exposed in the first place!)

I meant "there is *no* usage of the..."

But we'll still see
#define MACHINE something
and then later
#define MACHINE something-else

right? The compiler ought to complain about that, at point of the second #define; use or otherwise of the macro isn't relevant here.

thanks
-- PMM

#5 lore raw
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Marcel Apfelbaum
Quoted 8 lines · Marcel Apfelbaum
Quoted 4 lines · Peter Maydell

I'm confused; why doesn't this just result in a compiler error in the other direction when we try to #define MACHINE in QEMU and it's already been defined by the BSD headers?

Maybe because there is usage of the "MACHINE" define by the BSD library? (on Qemu context, of course! - meaning, it shouldn't even be exposed in the first place!)

I meant "there is *no* usage of the..."

Quoted 8 lines

But we'll still see
#define MACHINE something
and then later
#define MACHINE something-else

right? The compiler ought to complain about that, at point of the second #define; use or otherwise of the macro isn't relevant here.

Right! Sorry.
As Andreas said in IRC, BSDs do not build with -Werror

Quoted 4 lines

thanks
-- PMM

#2 lore raw
In reply to Peter Maydell
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Marcel Apfelbaum

Machine rewriting added MACHINE macro which is
already in use by other OpenBSD library.
Since qemu/sockets.h exposes the OpenBSD namespace,
the minimalistic approach is to add it as the first QEMU include.

---
 vl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -0
index f0fe48b..9f86e68 100644
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 
 #include <glib.h>
 
+#include "qemu/sockets.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/usb.h"
@@ -103,7 +104,6 @@ int main(int argc, char **argv)
 
 #include "disas/disas.h"
 
Quoted 8 lines

vl.c int main(int argc, char **argv) · line 108

Quoted 3 lines
vl.c +0 -1
-#include "qemu/sockets.h"
 
 #include "slirp/libslirp.h"

I'm confused; why doesn't this just result in a compiler error in the other direction when we try to #define MACHINE in QEMU and it's already been defined by the BSD headers?

Maybe because there is usage of the "MACHINE" define by the BSD library? (on Qemu context, of course! - meaning, it shouldn't even be exposed in the first place!)

Thanks,
Marcel

Quoted 3 lines

thanks
-- PMM