Opened 5 years ago

Closed 5 years ago

Last modified 5 months ago

#10883 closed defect (fixed)

conflict with glib 2.21 in GSocket

Reported by: sharkcz Owned by:
Priority: blocker Milestone: 2.8.11
Component: wxGTK Version: 2.8.10
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

glib starting in version 2.21 introduces support for network addresses and sockets in its I/O library (e.g. it has its own GSocket type) and that creates a symbol conflict with GSocket from src/unix/gsocket.cpp. This issues was during mass rebuild of current Fedora development (post F-11) sources.

In my opinion this conflict should be fixed in the stable branch (s/GSocket/intGSocket/g could work), because it will take some time before wxGTK 3.0 is released and even then distribution will have to support wxGTK 2.8, because not all application will be ported to wxGTK 3.0.

error message from build log:
/builddir/build/BUILD/wxGTK-2.8.10/bk-deps g++ -c -o coredll_gtk_gsockgtk.o -I./.pch/wxprec_coredll -DWXGTK -I./src/regex -DWXUSINGDLL -DWXMAKINGDLL_CORE -DwxUSE_BASE=0 -fPIC -DPIC -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I/builddir/build/BUILD/wxGTK-2.8.10/lib/wx/include/gtk2-unicode-release-2.8 -I./include -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -pthread -DORBIT2=1 -I/usr/include/gstreamer-0.10 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/gconf/2 -I/usr/include/orbit-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -DWX_PRECOMP -pthread -Wall -Wundef -Wno-ctor-dtor-privacy -g -O0 -I/usr/include/libgnomeprintui-2.2 -I/usr/include/libgnomeprint-2.2 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/libart-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/gail-1.0 -I/usr/include/gtk-2.0 -I/usr/include/freetype2 -I/usr/include/atk-1.0 -I/usr/lib/gtk-2.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fno-strict-aliasing ./src/gtk/gsockgtk.cpp
In file included from ./src/gtk/gsockgtk.cpp:21:
./include/wx/gsocket.h:40: error: using typedef-name 'GSocket' after 'class'
/usr/include/glib-2.0/gio/giotypes.h:120: error: 'GSocket' has a previous declaration here
In file included from ./include/wx/gsocket.h:179,

from ./src/gtk/gsockgtk.cpp:21:

./include/wx/unix/gsockunx.h:40: error: using typedef-name 'GSocket' after 'class'
/usr/include/glib-2.0/gio/giotypes.h:120: error: 'GSocket' has a previous declaration here
./src/gtk/gsockgtk.cpp: In function 'void _GSocket_GDK_Input(void*, gint, GdkInputCondition)':
./src/gtk/gsockgtk.cpp:34: error: 'struct _GSocket' has no member named 'Detected_Read'
./src/gtk/gsockgtk.cpp:36: error: 'struct _GSocket' has no member named 'Detected_Write'
./src/gtk/gsockgtk.cpp: In member function 'virtual bool GSocketGUIFunctionsTableConcrete::Init_Socket(GSocket*)':
./src/gtk/gsockgtk.cpp:56: error: 'struct _GSocket' has no member named 'm_gui_dependent'
./src/gtk/gsockgtk.cpp:57: error: 'struct _GSocket' has no member named 'm_gui_dependent'
./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Destroy_Socket(GSocket*)':
./src/gtk/gsockgtk.cpp:67: error: 'struct _GSocket' has no member named 'm_gui_dependent'
./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Install_Callback(GSocket*, GSocketEvent)':
./src/gtk/gsockgtk.cpp:72: error: 'struct _GSocket' has no member named 'm_gui_dependent'
./src/gtk/gsockgtk.cpp:75: error: 'struct _GSocket' has no member named 'm_fd'
./src/gtk/gsockgtk.cpp:83: error: 'struct _GSocket' has no member named 'm_server'
./src/gtk/gsockgtk.cpp:90: error: 'struct _GSocket' has no member named 'm_fd'
./src/gtk/gsockgtk.cpp: In member function 'virtual void GSocketGUIFunctionsTableConcrete::Uninstall_Callback(GSocket*, GSocketEvent)':
./src/gtk/gsockgtk.cpp:98: error: 'struct _GSocket' has no member named 'm_gui_dependent'
./src/gtk/gsockgtk.cpp:108: error: 'struct _GSocket' has no member named 'm_server'

Change History (3)

comment:1 follow-up: Changed 5 years ago by vadz

  • Milestone set to 2.8.11
  • Status changed from new to confirmed

Would simply removing #include <glib.h> from src/gtk/gsockgtk.cpp be enough to avoid this problem or will giotypes.h still get included from GDK headers indirectly even then?

Alternatively, what about this patch:

Index: 2.8/src/gtk/gsockgtk.cpp
===================================================================
--- 2.8/src/gtk/gsockgtk.cpp (revision 60599)
+++ 2.8/src/gtk/gsockgtk.cpp (working copy)
@@ -15,8 +15,13 @@
 #include <stdlib.h>
 #include <stdio.h>

+// newer versions of glib define its own GSocket but we unfortunately use this
+// name in our own (semi-)public header and so can't change it -- rename glib
+// one instead
+#define GSocket GlibGSocket
 #include <gdk/gdk.h>
 #include <glib.h>
+#undef GSocket

 #include "wx/gsocket.h"
 #include "wx/unix/gsockunx.h"

It is ugly, of course, but is the least intrusive solution I can think of.

TIA!

comment:2 in reply to: ↑ 1 Changed 5 years ago by sharkcz

Replying to vadz:

Would simply removing #include <glib.h> from src/gtk/gsockgtk.cpp be enough to avoid this problem or will giotypes.h still get included from GDK headers indirectly even then?

none of these tricks helped :-(

Alternatively, what about this patch:

Index: 2.8/src/gtk/gsockgtk.cpp
===================================================================
--- 2.8/src/gtk/gsockgtk.cpp (revision 60599)
+++ 2.8/src/gtk/gsockgtk.cpp (working copy)
@@ -15,8 +15,13 @@
 #include <stdlib.h>
 #include <stdio.h>

+// newer versions of glib define its own GSocket but we unfortunately use this
+// name in our own (semi-)public header and so can't change it -- rename glib
+// one instead
+#define GSocket GlibGSocket
 #include <gdk/gdk.h>
 #include <glib.h>
+#undef GSocket

 #include "wx/gsocket.h"
 #include "wx/unix/gsockunx.h"

It is ugly, of course, but is the least intrusive solution I can think of.

It's ugly, but it works, thanks.

comment:3 Changed 5 years ago by VZ

  • Resolution set to fixed
  • Status changed from confirmed to closed

(In [61009]) avoid name clashes with GSocket from glib 2.21+ (closes #10883)

Note: See TracTickets for help on using tickets.