RE: Using g_signal_connect in class

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

 



Thanks for the linkage info Chris.  I've been using static class members
successfully with the Sun compiler on Solaris, but I'll start declaring
my callbacks with c linkage to be standard conforming.  Sun's
documentation gives the same advice:
https://developers.sun.com/solaris/articles/mixing.html
   
-Anthony Vallone

-----Original Message-----
From: gtk-list-bounces@xxxxxxxxx [mailto:gtk-list-bounces@xxxxxxxxx] On
Behalf Of Chris Vine
Sent: Saturday, July 19, 2008 4:51 PM
To: Milosz Derezynski
Cc: gtk-list@xxxxxxxxx; Vallone, Anthony
Subject: Re: Using g_signal_connect in class

On Sat, 19 Jul 2008 16:40:17 +0200
"Milosz Derezynski" <internalerror@xxxxxxxxx> wrote:

> I think he meant that in order to use the function with 
> g_signal_connect(), a C linkage is not needed (and i think this is 
> actually right, too).

No, g_signal_connect() takes a function pointer and in C++ function
pointers have a linkage type.  For GObject/GTK functions they have C
linkage type.

By default, when compiled in a C++ environment non-member functions and
non-member function pointers have C++ linkage type, so that amongst
other things functions can be overloaded, but some compilers may also
keep arguments on the stack for function calls with C linkage
differently from functions calls with C++ linkage.  The way to give them
C linkage type is to declare them extern "C".

Passing functions with C++ linkage type as GSignal callbacks works with
gcc/g++, but it is not guaranteed by the standard.

For more discussion you might want to read section 9.2.5 of TC++PL.

Chris

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux