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



Ulric Eriksson wrote:

> OK, here is the problem:
> 
> It has been asserted that using Glib, a gint can be safely converted to
> gpointer and back. For this to hold water, something needs to make it so.
> 
> This "something" cannot be C, because conversions between pointers and
> integral types are implementation-defined. And it cannot be Glib itself,
> because Glib doesn't even try. What remains is perhaps to document that
> Glib is only portable to implementations where certain conditions are
> satisfied.

>From Solaris 2.6 & 7 <sys/int_types.h>:

/*
 * intptr_t and uintptr_t are signed and unsigned integer types large enough
 * to hold any data pointer; that is, data pointers can be assigned into or
 * from these integer types without losing precision.
*/
#if defined(_LP64) || defined(_I32LPx)
typedef long                    intptr_t;
typedef unsigned long           uintptr_t;
#else
typedef int                     intptr_t;
typedef unsigned int            uintptr_t;
#endif

At the beginning of include file, you can read:

 * This file, <sys/int_types.h>, is part of the Sun Microsystems implementation
 * of <inttypes.h> as proposed in the ISO/JTC1/SC22/WG14 C committee's working
 * draft for the revision of the current ISO C standard, ISO/IEC 9899:1990
 * Programming language - C.

-- 
 .-.   .-.    Life is a sexually transmitted disease.
(_  \ /  _)
     |        dave@srce.hr
     |        dave@fly.cc.fer.hr



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