[Spice-devel] [PATCH spice-gtk v2 3/4] Don't wrap included headers in G_BEGIN|END_DECLS
Jonathon Jongsma
jjongsma at redhat.com
Thu Sep 24 15:20:28 PDT 2015
Only the local declarations should be declared extern "C", otherwise it
can result in unexpected errors such as this (encountered while re-ordering
some include statements for a different patch):
CC channel-inputs.lo
In file included from /usr/include/glib-2.0/glib/gmacros.h:38:0,
from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from ../../src/spice-channel.h:27,
from ../../src/channel-inputs.h:25,
from ../../src/channel-inputs.c:20:
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/include/stddef.h:147:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^
---
src/smartcard-manager.h | 4 ++--
src/spice-channel.h | 5 +++--
src/spice-widget-priv.h | 4 ++--
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/smartcard-manager.h b/src/smartcard-manager.h
index 4cfbeb2..756c9ff 100644
--- a/src/smartcard-manager.h
+++ b/src/smartcard-manager.h
@@ -22,11 +22,11 @@
#error "Only <spice-client.h> can be included directly"
#endif
-G_BEGIN_DECLS
-
#include "spice-types.h"
#include "spice-util.h"
+G_BEGIN_DECLS
+
#define SPICE_TYPE_SMARTCARD_MANAGER (spice_smartcard_manager_get_type ())
#define SPICE_SMARTCARD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_SMARTCARD_MANAGER, SpiceSmartcardManager))
#define SPICE_SMARTCARD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_SMARTCARD_MANAGER, SpiceSmartcardManagerClass))
diff --git a/src/spice-channel.h b/src/spice-channel.h
index 6214071..5432c96 100644
--- a/src/spice-channel.h
+++ b/src/spice-channel.h
@@ -22,13 +22,14 @@
#error "Only <spice-client.h> can be included directly"
#endif
-G_BEGIN_DECLS
-
#include <gio/gio.h>
+
#include "spice-types.h"
#include "spice-glib-enums.h"
#include "spice-util.h"
+G_BEGIN_DECLS
+
#define SPICE_TYPE_CHANNEL (spice_channel_get_type ())
#define SPICE_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SPICE_TYPE_CHANNEL, SpiceChannel))
#define SPICE_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SPICE_TYPE_CHANNEL, SpiceChannelClass))
diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 0e1f661..682e889 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -18,8 +18,6 @@
#ifndef __SPICE_WIDGET_PRIV_H__
#define __SPICE_WIDGET_PRIV_H__
-G_BEGIN_DECLS
-
#include "config.h"
#ifdef WITH_X11
@@ -36,6 +34,8 @@ G_BEGIN_DECLS
#include "spice-common.h"
#include "spice-gtk-session.h"
+G_BEGIN_DECLS
+
#define SPICE_DISPLAY_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE((obj), SPICE_TYPE_DISPLAY, SpiceDisplayPrivate))
--
2.1.0
More information about the Spice-devel
mailing list