Re: GLib and 64-bit Windows



> > intptr_t and uintptr_t? Does the current MS compiler have <stdint.h>?

> Between stdio.h, stdlib.h, assert.h, and windows.h it exists and is 64-bit.
> Would the appropriate thing to be to change the glib code where the 
> aforementioned assumptions occur to use these types?

You mean for instance for the n_bytes parameter to g_malloc() and
friends?

I'm not sure. This can be considered as an API change even if the type
is the same size and signedness as the old one on the existing
plaforms. intprt_t and uintprt_t also don't exist on all
platforms. Maybe preprocessor macros is the only way out, i.e. having
a macro G_NBYTES_T (or whatever) that expands to gulong on everything
except Win64 and other similar platforms, where it would be size_t?

I.e., in gtypes.h or gmacros.h:

#if GLIB_SIZEOF_LONG < GLIB_SIZEOF_SIZE_T
#define G_NBYTES_T gsize
#else
#define G_NBYTES_T gulong
#endif

and in gmem.h:

gpointer g_malloc         (G_NBYTES_T    n_bytes) G_GNUC_MALLOC;
gpointer g_malloc0        (G_NBYTES_T    n_bytes) G_GNUC_MALLOC;
gpointer g_realloc        (gpointer      mem,
                           G_NBYTES_T    n_bytes) G_GNUC_WARN_UNUSED_RESULT;
void     g_free           (gpointer      mem);
gpointer g_try_malloc     (G_NBYTES_T    n_bytes) G_GNUC_MALLOC;
gpointer g_try_malloc0    (G_NBYTES_T    n_bytes) G_GNUC_MALLOC;
gpointer g_try_realloc    (gpointer      mem,
                           G_NBYTES_T    n_bytes) G_GNUC_WARN_UNUSED_RESULT;

Yeah, a bit ugly.

--tml



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