Re: [gtk-list] Re: More tutorial



On Tue, 29 Jul 1997, Martin Norb{ck wrote:

> On Tue, 29 Jul 1997, Ian Main wrote:
> 
> >      /* this is a callback function. the data arg is ignored..
> >       * More on callbacks below. */
> >      void hello (gpointer *data)
> >      {
> >         g_print ("Hello World\n");
> >      }
> [SNIP]
> >         * defined above. */
> >        gtk_signal_connect (GTK_OBJECT (button), "clicked",
> >                            GTK_SIGNAL_FUNC (hello), NULL);
> One little comment.
> The clicked signal has declaration:
> void GtkButton::Clicked( GtkButton* button );
> which means that the callback really should have type
> void hello( GtkButton* button, gpointer* data );
> where the button argument is the button that sent the signal.
> 
> Since you are not using the data in this example there is nothing to worry
> about, but if you try to use it you will probably get an error.
> 
> Since the C calling convention allows any number of arguments to any function,
> the above code will work. The type checker can't check this either, because
> the hello function is casted anyway, so it's a bit of a problem really.
> 
> ----- BEGIN FLAME PROTECTION -----
> I hope I am right; I gathered this information by reading the source code. If I
> am wrong could someone please tell me, because that may fix some of the bugs
> in my programs!
> ----- END FLAME PROTECTION -----
> 
> /norpan
> 
> Signature left blank

Nope, your right.  I just did it from memory, and figured it'd be better
to have the callback function declared properly so it makes a better
template.

Thanks to everyone for your suggestions so far :)  I'm incorporating the
changes..

Ian




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