types - Correct way to cast a gpointer to a GType -
i trying create macro cast gpointer gtype , vice versa. have created following macros using relevant api documentation guide:
#ifdef gtype_to_pointer   #define gtype_to_pointer (x) (gsize_to_pointer (x)) #endif #ifdef gpointer_to_gtype   #define gpointer_to_gtype(p) (gpointer_to_size (p)) #endif   i have casting done follows:
type = (gtype)g_hash_table_lookup(typetable, guint_to_pointer(tflag));   i want casting follows:
type = gpointer_to_gtype(g_hash_table_lookup(typetable, guint_to_pointer(tflag)));   // stuff   g_hash_table_insert(typetable,                      guint_to_pointer(tflag),                      gtype_to_pointer(type));    however, seems problematic compiler indicating implicit declaration has been made g_hash_table_lookup cast , third argument of following g_hash_table_insert
warning: implicit declaration of function 'gpointer_to_gtype'           warning: implicit declaration of function 'gtype_to_pointer' warning: passing argument 3 of 'g_hash_table_insert' makes pointer integer without cast [-wint-conversion]   also when try run wrapper java: symbol lookup error of undefined symbol: gpointer_to_gtype.
can advise on might able fix this?
ok seem have figured out myself now....
firstly, using wrong test in checking gtype_to_pointer , gpointer_to_gtype since variables wanted define compiler not find them , definition never being made.
secondly, using undefined variables argument correct definition these macros seems be:
#ifdef gpointer_to_size   #define gpointer_to_gtype(gpointer) (gpointer_to_size (gpointer)) #endif #ifdef gsize_to_pointer   #define gtype_to_pointer(gtype) (gsize_to_pointer(gtype)) #endif   which means casting functions compile without problems.
Comments
Post a Comment