Re: Using g_signal_connect in class



On Sat, 19 Jul 2008 16:40:17 +0200
"Milosz Derezynski" <internalerror gmail com> 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



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