Re: passing values to functions - question repeated
- From: Stephen Witkop <switk yahoo com>
- To: davidgn servidor unam mx
- Cc: gtk-list <gtk-list gnome org>
- Subject: Re: passing values to functions - question repeated
- Date: 29 Jan 2002 20:41:28 -0500
On Tue, 2002-01-29 at 16:48, David Eduardo Gomez Noguera wrote:
> On Tue, 29 Jan 2002 09:18:43 -0800 (PST)
> Shiraz Baig <shiraz_baig yahoo com> wrote:
>
> > Hi,
> > I am going to repeat my question and try to clarify
> > it further.
> >
> > We know that in any program, whenever we call a
> > function, we have to pass some data to that
> > function and then only that function can use that
> > data.
> >
> > In my program (that I posted earlier), The function to
> > be called is:
> > -----------------------------------
> > void hello( GtkWidget *widget,
> > gpointer data )
> > {
> > g_print ("Hello World\n");
> > }
> > -----------------------------------
> > On the other hand, In the main() we are calling this
> > function as follows:
> >
> > gtk_signal_connect (GTK_OBJECT (button),"clicked",
> > GTK_SIGNAL_FUNC (hello),
> > NULL);
> >
> >
> > Now my question is as follows:
> >
> > We are passing NULL as data to the function
> > "hello". Yet, hello function (as declared above) is
> > showing that it has been passed two arguments, the
> > widget and the gpointer.
> > Why doesn't the compiler complain that you are passing
> > NULL to the function and then you are trying to use
> > arguments in the function?
>
> because NULL is the argument.
> If you do a printf("%p",gpointer); on your function you will find its value is NULL (whatever it might be in such and such plataform, i.e. -1 or 0, i dont know)
> >
>
The gpointer data argument is there for the programmer to use to pass
some value to the callback function that you are connecting to. If you
don't need it then you pass NULL and ignore it.
Stephen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]