Re: [gtk-list] Re: How to use a gpointer?
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: How to use a gpointer?
- Date: Thu, 4 Mar 1999 23:30:53 +0100 (CET)
On Thu, 4 Mar 1999, Ulric Eriksson wrote:
>
> On Thu, 4 Mar 1999, Tim Janik wrote:
>
> > after having seen various statements on this topic,
> > i think it's time to clarify some points.
> >
> > for GLib to compile on several different platforms, certain
> > assumptions can be made about its data types.
> >
> > gint8 sizeof (gint8) = 1 byte, signed
> > guint8 sizeof (guint8) = 1 byte, unsigned
> > gint16 sizeof (gint16) = 2 bytes, signed
> > guint16 sizeof (guint16) = 2 bytes, unsigned
> > gint32 sizeof (gint32) = 4 bytes, signed
> > guint32 sizeof (guint32) = 4 bytes, unsigned
> > gint is merely an alias for the system's int and guarranteed
> > to be >= 4 bytes in size, signed.
> > guint is and unsigned gint.
> > glong is an alias for the system's long and guarranteed to be >=
> > sizeof (gint), signed.
> > gulong is an unsigned glong.
> > gpointer is essentially a void* and guarranteed to be >= sizeof (gint)
> > and <= sizeof (glong) in size.
>
> 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.
the fact that some typedefs are not special cased in glibconfig.h doesn't mean
that one couldn't make assumptions about them ;)
>
> Ulric
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]