MESSAGE
| DATE | 2002-04-24 |
| FROM | Jonathan Bober
|
| SUBJECT | Re: [hangout] C problem
|
From owner-hangout-desteny-at-mrbrklyn.com Wed Apr 24 01:08:18 2002 Received: (from mdom-at-localhost) by www2.mrbrklyn.com (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id g3O58Fc13496 for hangout-desteny; Wed, 24 Apr 2002 01:08:15 -0400 Received: from smtp01.mrf.mail.rcn.net (smtp01.mrf.mail.rcn.net [207.172.4.60]) by www2.mrbrklyn.com (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP id g3O58FC13490; Wed, 24 Apr 2002 01:08:15 -0400 Received: from [204.74.5.136] (helo=ziggy) by smtp01.mrf.mail.rcn.net with smtp (Exim 3.33 #10) id 170F0F-00036n-00; Wed, 24 Apr 2002 01:07:39 -0400 Date: Wed, 24 Apr 2002 00:00:16 -0500 From: Jonathan Bober To: Ruben I Safir Cc: hangout-at-nylxs.com Subject: Re: [hangout] C problem Message-Id: <20020424000016.101a03b4.jwb235-at-nyu.edu> In-Reply-To: <20020424000755.C12350-at-www2.mrbrklyn.com> References: <20020424000755.C12350-at-www2.mrbrklyn.com> X-Mailer: Sylpheed version 0.7.4 (GTK+ 1.2.10; i386-debian-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hangout-at-mrbrklyn.com Precedence: bulk Reply-To: Jonathan Bober List: New Yorkers Linux Scene Admin: To unsubscribe send unsubscribename-at-domian.com to hangout-request-at-www2.mrbrklyn.com X-Keywords: X-UID: 16299 Status: RO Content-Length: 2381 Lines: 76
First, what is g_hash_table_new(), if those warnings are important to you?
Second, hTable must be declared to be something before a value is assigned to it. If it is indeed declared above main(), (which I guess it would be, based on the error) it must be of the same type that g_hash_table_new returns.
In other words, if g_hash_table_new looks like "g_hash_table* g_hash_table_new(g_hash_function*, g_hash_compare_function*)" (just guesses,) then hTable must be of type g_hash_table* and HashFunction and HashCompare must be the proper types of functions. The lvalue error sounds like it might be something like g_hash_table_new returns a g_hash_table* and hTable is a g_hash_table (not a pointer.)
In general, if a function is declared as: type function();
Then before writing the statement: x = function();
You must write the statement: type x;
On Wed, 24 Apr 2002 00:07:55 -0400 Ruben I Safir wrote:
> > int main(int argc, char *argv[]){ > int ret = 0; > hTable = g_hash_table_new(HashFunction, HashCompare); > while(1){ > if(! ret=scanf("%255s", buff_key)) break; <====LINE 35 > if(!scanf("%255s", buff_val)) break; > g_print("%s %s %d \n", buff_key, buff_val, ret); > > g_hash_table_insert(hTable, buff_key, buff_val); > } > > > > hash.c: In function `main': > hash.c:33: warning: passing arg 1 of `g_hash_table_new' from > incompatible pointer type hash.c:33: warning: passing arg 2 of > `g_hash_table_new' from incompatible pointer type hash.c:35: invalid > lvalue in assignment > > -- > __________________________ > > Brooklyn Linux Solutions > __________________________ > http://www.mrbrklyn.com - Consulting > http://www.brooklynonline.com - For the love of Brooklyn > http://www.nylxs.com - Leadership Development in Free Software > http://www.nyfairuse.org - The foundation of Democracy > http://www2.mrbrklyn.com/resources - Unpublished Archive or stories > and articles from around the net http://www2.mrbrklyn.com/mp3/dr.mp3 - > Imagine my surprise when I saw you... > http://www2.mrbrklyn.com/downtown.html - See the New Downtown > Brooklyn.... > > 1-718-382-5752 > > > > ____________________________ > New Yorker Linux Users Scene > Fair Use - > because it's either fair use or useless.... ____________________________ New Yorker Linux Users Scene Fair Use - because it's either fair use or useless....
|
|