qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] disas: Fix build with glib2.0 >=2.67.3


From: Daniel P . Berrangé
Subject: Re: [PATCH] disas: Fix build with glib2.0 >=2.67.3
Date: Wed, 24 Feb 2021 11:04:01 +0000
User-agent: Mutt/2.0.5 (2021-01-21)

On Wed, Feb 24, 2021 at 08:38:30AM +0100, Christian Ehrhardt wrote:
> On Tue, Feb 23, 2021 at 5:12 PM Daniel P. Berrangé <berrange@redhat.com> 
> wrote:
> >
> > On Tue, Feb 23, 2021 at 03:43:48PM +0000, Peter Maydell wrote:
> > > On Tue, 23 Feb 2021 at 15:03, Christian Ehrhardt
> > > <christian.ehrhardt@canonical.com> wrote:
> >
> > We need to make headers that need to be used from C++ code follow
> > the pattern:
> >
> >     #include <foo1>
> >     #include <foo2>
> >     #include <foo3>
> >     ...all other includs..
> >
> >     extern "C" {
> >         ..
> >         only the declarations, no #includes
> >         ...
> >     };
> 
> While I can follow the words and always awesome explanations by Daniel,
> I must admit that I'm a bit lost at what a v2 of this could look like.
> 
> osdep.h as of today unfortunately isn't as trivial as 1. include 2.
> declarations.
> There are late includes deep in cascading ifdef's and we all know that "just
> moving includes around for the above fix to work in an easy way" in headers
> will likely (maybe even silently) break things.
> 
> So I wonder is this going to become a massive patch either moving a lot or
> adding many extern C declarations all over the place in osdep-h? Or did I
> just fail to see that there is an obviously better approach to this?

I don't think it will need reordering osdep.h.

Most of the #include are system headers, which should already be
protected by 'extern "C"' themselves if needed.


So from osdep.h I think something like this is likely sufficient:

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index ba15be9c56..7a1d83a8b6 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -126,6 +126,7 @@ extern int daemon(int, int);
 #include "glib-compat.h"
 #include "qemu/typedefs.h"
 
+extern "C" {
 /*
  * For mingw, as of v6.0.0, the function implementing the assert macro is
  * not marked as noreturn, so the compiler cannot delete code following an
@@ -722,4 +723,6 @@ static inline int platform_does_not_support_system(const 
char *command)
 }
 #endif /* !HAVE_SYSTEM_FUNCTION */
 
+}
+
 #endif


We'll also need to them protect any local headers we use before this point.

$ grep #include ../../../include/qemu/osdep.h  | grep -v '<'
#include "config-host.h"
#include CONFIG_TARGET
#include "exec/poison.h"
#include "qemu/compiler.h"
#include "sysemu/os-win32.h"
#include "sysemu/os-posix.h"
#include "glib-compat.h"
#include "qemu/typedefs.h"

and transitively through that list, but I think there's no too many
more there.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




reply via email to

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