Re: [gtk-list] Gtk-- connect() woes (was Re: gtk-- information ??)
- From: Tero Pulkkinen <terop students cc tut fi>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Gtk-- connect() woes (was Re: gtk-- information ??)
- Date: 18 Feb 1998 03:02:06 +0200
Jon Trowbridge <trow@emccta.com> writes:
ÿ> I was not able, however, to get signals whose callbacks take arguments to
> work properly. I took the following code snippet:
[SNIP]
> connect(ebox.button_press_event, button_press_callback_fn);
Yeah, I think you need to have
connect(ebox.button_press_event, &button_press_callback_fn);
hmm, I think I might have many examples in the web page without the extra
&.:) I'll check them all ... :)
> no matching function for call to
> `connect (Signal_proxy1<int,Gtk_Widget,_GdkEventButton *> &,
> void ()(_GdkEventButton *))'
>
> /usr/local/include/gtk--sig.h:735:
> candidates are:
> connect(Signal0 &, void (*)())
>
> /usr/local/include/gtk--sig.h:1172:
> connect<int, Gtk_Widget, void ()(_GdkEventButton *), _GdkEventButton *>
> (Signal_proxy1<int,Gtk_Widget,_GdkEventButton *> &,
> void ( &)(_GdkEventButton *))
>
> I tried looking at gtk--sig.h line 1172, but it seems to involve
> macro-expansion magic and I ran screaming in the other direction...
>
> But notice what it is suggesting as a match: a connect() whose second arg
> is a void ( &)(_GdkEventButton *)). If I'm not mistaken, isn't that
> a *reference* to a void function taking a _GdkEventButton* as an argument?
Yes. This is called "function object" in the STL for example. And templates
do make a difference between reference/pointer.
Hmm, I wonder why that doesnt match the function object -version of connect()..
It should. (tho those are supposed to be used with &...)
> And there is certainly no mention that I can find of references to functions
> in the latest edition of Stroustrup.
It can only happen in template expansion. Templates are special - they do
always want perfect match of the signature.
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]