Re: gssize, gsize



On 6 Jun 2000, Federico Mena Quintero wrote:

> Owen Taylor <otaylor@redhat.com> writes:
> 
> > Currently, glib.h has
> > 
> >  #define gint32 gssize
> >  #define guint32 gsize
> > 
> > This strikes me as a bad idea. On a 64 bit platforms, attempts to 
> > use these in place of ssize_t and size_t are going to produce warnings
> > and, in extreme cases, incorrect code.
> > 
> > If we don't want to simply include <stddef.h> and use size_t and ssize_t,
> > which strikes me as the right course. We should test for the sizes of
> > these types and mirror that in gssize and gsize.
> > 
> > Right?
> 
> We should just use size_t and ssize_t.

no, except for void, we use only g/G prefixed types in glib's API and
implementation and i don't remember agreeing to change that.
so as far as size_t and ssize_t go, iirc, they were added because of
GDate and for consistency of usage, which is fine.
owen is right though, that we can't simply use
typedef gint32  gssize;
typedef guint32 gsize;
and be done there, that's a portability bug.
so as he already mentioned, we either need to special case the
gssize+gsize typedefs in glibconfig.h according to some configure.in
magic, or include <stddef.h> right away and typedef them in terms of
size_t and ssize_t.
so far the glib.h policy of adding additional include files has been:

1) don't add any
2) add an include file if we really can't do without including it, i.e.
   due to dependancies of system/compiler specifc actualities (stdarg.h,
   float.h, limits.h)
3) don't add include files that export function prototypes, read 1)
   again. (we've been bitten by this before, we don't even include
   <string.h> eventhough you need it when using g_memmove())

looking at stddef.h, it doesn't come with new function declarations,
and basically only contains macro magics to get size_t, ssize_t and
a couple of other types right which we may want to also wrap in the future.

so the right thing is to do here is to include stddef.h in
glibconfig.h and put

typedef ssize_t gssize;
typedef size_t  gsize;

there as well.
platforms that don't come with <stddef.h> (are there any? windows?)
can have their wraper magic there as well then.

> 
>   Federico
> 

---
ciaoTJ





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