Re: a reminder about 64-bit machines




"Gareth Pearce" <tilps hotmail com> writes:
> >
> >I don't see why ... usually, these warnigns just indicate
> >that an standard cast from void * to int needs to be switched
> >to use the G[U]INT_TO_POINTER() / GPOINTER_TO_[U]INT macros.
> >
> >It's very seldom that when you are storing an integer in a pointer
> >you actually want to store a 64-bit quanity.
>
> umm, the problems which occur are when your doing pointer arithmatic
> and storing differences between pointers in integer temp variables
> (instead of ptr_diff_t).  Or storing pointers in integers.  Maybe all
> the cases in the code are just ints being stored in pointers, but I
> thought I had seen some that were not.

I don't think that will give you that particular warning
(The result of pointer arithmetic is an integral
type, not a pointer, so it's not a cast from a pointer to
an integer of a different size.) As far as I know, there
is no way to get GCC to warn about casts from size_t to
int when int is smaller ... and that's probably good
since there would be lots of false positives.

hmm okay - you are indeed correct - however the possibility of pointers being stored into ints remains.

Interesting that gcc will complain about long* being cast to int* - even without the allignment issue but wont complain about long to int.
(wonder if I can hack it so it does - just for debugging purposes)

For 2.0, I actually went through and tried to make GLib work
with 64-bit quantities

 - Use size_t/ssize_t for string sizes / byte counts
 - Use long for counts of non-byte objects.

But in almost all places, 32 bits is perfectly fine.

indeed glib looks quite good and it doesnt have any of the warnings of the type I mention in the first place anyway. And indeed its not frequent by any measure that 64bits is needed.

Regards,
Gareth


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




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