gnu-arch-users
[Top][All Lists]
Advanced

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

Re: [Gnu-arch-users] 64-bit cleaning [PATCH]


From: Jan Hudec
Subject: Re: [Gnu-arch-users] 64-bit cleaning [PATCH]
Date: Sun, 7 Sep 2003 01:28:34 +0200
User-agent: Mutt/1.5.4i

On Sat, Sep 06, 2003 at 15:59:11 -0500, John Goerzen wrote:
>  * Casting ints to void * and back (int is not the same size as
>    pointers on Alpha)
> 
>    My fix: cast longs instead of ints since they are the same size
>    on every modern Unix I'm aware of.
> 
>    (Some debate exists on the proper way to do this; some advocate
>     the size_t type instead, but in my experience, long is most
>     portable.  Ideally, though, ints should not be casted to pointers
>     at all; a pointer to the int should be passed, or a union
>     created to hold them both.  I tried to keep my changes as
>     minimal as possible, and thus took neither of these actions.)

Glib manual says to this topic, that on all platforms in use (perhaps
except something very obscure -- C spec does not quarantee this)

sizeof(int) <= sizeof(void *) <= sizeof(long)

but neither equality holds everywhere. Thus one can safely pass int
values around in void * and void * values in long.

-------------------------------------------------------------------------------
                                                 Jan 'Bulb' Hudec 
<address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]