MESSAGE
DATE | 2002-04-24 |
FROM | Jonathan Bober
|
SUBJECT | Re: [hangout] C problem
|
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....
|
|