Re: [gtk-list] Re: How to use a gpointer?




On Thu, 4 Mar 1999, Tim Janik wrote:

> On Thu, 4 Mar 1999, Ulric Eriksson wrote:
> 
> > Well spank me with a wet noodle if I'm wrong, but here is cut-and-paste
> > from glib.h of 1.2:
> > 
> > 8<--------
> > typedef int    gint;
> > ...
> > typedef void* gpointer;
> > 8<--------
> > 
> > There is nothing in these typedefs that guarantees that a gint will fit
> > in a gpointer.
> > 
> > Some of the headers are generated when Glib is compiled, but not glib.h,
> > so I suppose that the above is the same on the Alpha.
> 
> yes, and on the alpha sizeof(gpointer)=8, sizeof(gint)=4 and sizeof(glong)=8,
> so an int can be stored in a pointer without lossage and a pointer can be
> stored in a long without lossage, so my above summary still holds.
> in fact, we haven't yet encountered a 32bit system (or 64bit system for that
> matter) where sizeof(gpointer) would be less than 4, and i guess we never
> will, so that pretty much makes up the above guarrantee.

Not really; it just means that it works on one more system, at least using
one compiler. Since C makes no such guarantees, it really has to be
"special cased" to be useful. As it is, it just looks like name space
pollution: an obviously nonportable operation is renamed, hidden in a
macro and claimed to be portable. Implementation-defined stuff like
conversion between pointers and integral types is best handled by
autoconf.

Ulric



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