Re: passing values to functions - question repeated



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)
> 
> Thanks
> Shiraz
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Great stuff seeking new owners in Yahoo! Auctions! 
> http://auctions.yahoo.com
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list


-- 
ICQ: 15605359 Bicho
                                  =^..^=
First, they ignore you. Then they laugh at you. Then they fight you. Then you win. Mahatma Gandhi.
........Por que no pensaran los hombres como los animales? Pink Panther........
-------------------------------気検体の一致------------------------------------
暑さ寒さも彼岸まで。
アン アン アン とっても大好き


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