Re: [gtk-list] Re: More about types...



Drazen Kacar <dave@srce.hr> writes:

> Havoc Pennington wrote:
> 
> > To printf it, come to think of it, just do this:
> > 
> > size_t s;
> > printf("%d", (int)s);
> > 
> > If you are overflowing int in your size_t you're doing evil things anyway.
> 
> In case size_t was 64 bit, but the current value fits in 32 bits,
> that would work on Alpha, but not on SPARC.

You are wrong here.  C is required to perform the cast correctly in
the case you described regardless of endianness.  You are assuming
that casting long to int is equivalent to *(int *)&s (which would
indeed produce bogus results on v9 sparcs), but it's not.

Of course, none of this would help when printing the size of a file
that is >2G.  The whole guint/gint/gint32/... stuff is terminally
broken, because it basically buys you nothing except, as you well put
it, a false sense of security.



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