Compile fails on complex structures in glib?




(Slackware 3.5 - glib1.1.11).
I have tried and failed to get GHashTable or any other structure in
glib that is something other than a simple type.  As near as I can
tell everything that depends on it seems to work fine (gdk,gtk,gnome..).
What am I missing here?

$ cc -o tiger tiger.c -I/usr/lib/glib/include -lglib
tiger.c:33: conflicting types for `hash_table'
tiger.c:31: previous declaration of `hash_table'
tiger.c:33: warning: initialization makes integer from pointer without a cast
tiger.c:33: initializer element is not constant
tiger.c:33: warning: data definition has no type or storage class
make: *** [tiger] Error 1
$ 

/* ---------------- */

#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <unistd.h>
#include <glib.h>

#include "tiger.h"

guint
hash_pass(gconstpointer key)
{
 return (guint) *(((struct passwd *)key)->pw_name);
}

gint
hash_pass_compare(gconstpointer a, gconstpointer b)
{
 return !strcmp(((struct passwd *) a)->pw_name,((struct passwd *)b)->pw_name);
}

GHashTable* hash_table;
hash_table = (GHashTable *)g_hash_table_new(hash_pass,hash_pass_compare);

...


-- 
David Nicklay _________ Ventura  O-
     \  /_ .__|_   .__.  o|| _ 
      \/(/_| ||_|_||(_|\/|||(/_ 
    http://www.avana.net/~ventura/



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