Re: How to use a gpointer?

On Thu, Mar 04, 1999 at 01:50:15PM +0300, Alexander Kotelnikov wrote:

> More if you have there are crazy systems (e.g. DOS) were
> sizeof(int a)!=sizeof(int b) if a,b are stored in different memory parts.

Did't know about this ;-)

> * casting scalar type (int) to pointer (gpointer) is not good idea anyway.

True, but glib docs advise You to do it ;-) Glib is suposed to be
cross platform and use translation between gint and gpointer internaly
(se funktion g_int_hash() for example) so I guess it works (possably
by garanteeing that gint is newer biger then gpointer - whatever the
size of a 'plain' int is)...

Having a gparam who is a union of int, void* and maybe something more
vould be nicer but I don't remember if ansi-C allow passing unions as
parameters (used C++ for too long ;-)

PS Is ther a clear document declaring what one can safely do (cast)
with the varius gfoo types? DS


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