Date: Sun, 20 Feb 2005 00:14:03 +0100 From: Steven <freebsd@gizm0.org> To: gert.cuykens@gmail.com Cc: "Chad Leigh -- Shire. Net LLC" <chad@shire.net> Subject: Re: c++ Message-ID: <4217C83B.8060502@gizm0.org> In-Reply-To: <ef60af0905021915074e5d2929@mail.gmail.com> References: <ef60af09050219015116024f83@mail.gmail.com> <5b8472dd5925a0b0b59f15cd9f8e15f3@shire.net> <ef60af0905021915074e5d2929@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
Gert Cuykens wrote:
>On Sat, 19 Feb 2005 02:57:53 -0700, Chad Leigh -- Shire. Net LLC
><chad@shire.net> wrote:
>
>
>>On Feb 19, 2005, at 2:51 AM, Gert Cuykens wrote:
>>
>>
>>
>>>On Thu, 17 Feb 2005 13:17:51 +0100, Hubert SokoĊowski
>>><h.sokolowski@wsisiz.edu.pl> wrote:
>>>
>>>
>>>>On Thu, 17 Feb 2005 13:05:43 +0100
>>>>Gert Cuykens <gert.cuykens@gmail.com> wrote:
>>>>
>>>>
>>>>
>>>>>static void callback( GtkWidget *widget, gpointer data ){
>>>>> g_print ("Hello again - %s was pressed\n", (gchar *) data);
>>>>>}
>>>>>
>>>>>why do they put () around gchar ?
>>>>>why can it not be gchar *data ?
>>>>>
>>>>>
>>>>You should learn some more about programming in C before you start
>>>>writing GTK apps.
>>>>
>>>>hs
>>>>
>>>>
>>>Does anybody want to explain what the () thingies are around gchar * ?
>>>
>>>
>>>
>>It is a typecast -- coercing "data" to be of type (gchar *) to the
>>compiler when matching parameter types at compiler time.
>>
>>Chad
>>
>>
>>
>
>lol :) I wish you could see the expression on my face while reading it :)
>
>Why can i not do this ?
>
>g_print ("Hello again - %s was pressed\n", gchar *data);
>or this
>gchar *data;
>g_print ("Hello again - %s was pressed\n", *data);
>or this
>gchar *data;
>g_print ("Hello again - %s was pressed\n", data);
>
>What does coercing mean ?
>Why does the compiler have to match parameters ?
>
>PS what is the difference between ?
> A=*data
> A=data
> A=&data
>_______________________________________________
>freebsd-questions@freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
>
>
You should really get a book about programming or ask your teacher.
These are basic questions about c/c++ programming.
But to answer your question: You need to cast the data, so you can hand
data of different but matching type to the function. (eg. you have a
pointer to int but the function expects a plain pointer)
Steven
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4217C83B.8060502>
