From owner-freebsd-questions@FreeBSD.ORG Sat Feb 19 23:14:13 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7ABE516A4CE for ; Sat, 19 Feb 2005 23:14:13 +0000 (GMT) Received: from gizm0.org (gizm0.org [212.114.209.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1C19F43D39 for ; Sat, 19 Feb 2005 23:14:13 +0000 (GMT) (envelope-from freebsd@gizm0.org) Received: from localhost (localhost.org [127.0.0.1]) by gizm0.org (Postfix) with ESMTP id 367C517019; Sun, 20 Feb 2005 00:14:11 +0100 (CET) Received: from gizm0.org ([127.0.0.1]) by localhost (gizm0.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 55588-11; Sun, 20 Feb 2005 00:14:04 +0100 (CET) Received: from [192.168.0.16] (DSL01.212.114.229.80.NEFkom.net [212.114.229.80]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by gizm0.org (Postfix) with ESMTP; Sun, 20 Feb 2005 00:14:04 +0100 (CET) Message-ID: <4217C83B.8060502@gizm0.org> Date: Sun, 20 Feb 2005 00:14:03 +0100 From: Steven User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: gert.cuykens@gmail.com References: <5b8472dd5925a0b0b59f15cd9f8e15f3@shire.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: amavisd-new at gizm0.org cc: freebsd-questions@freebsd.org cc: "Chad Leigh -- Shire. Net LLC" Subject: Re: c++ X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Feb 2005 23:14:13 -0000 Gert Cuykens wrote: >On Sat, 19 Feb 2005 02:57:53 -0700, Chad Leigh -- Shire. Net LLC > wrote: > > >>On Feb 19, 2005, at 2:51 AM, Gert Cuykens wrote: >> >> >> >>>On Thu, 17 Feb 2005 13:17:51 +0100, Hubert SokoĊ‚owski >>> wrote: >>> >>> >>>>On Thu, 17 Feb 2005 13:05:43 +0100 >>>>Gert Cuykens 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