Re: Casting between 64bit and 32bit
- From: Valentin Nechayev <netch@xxxxxxxxxxxxxxxx>
- Date: Thu, 29 Dec 2005 11:46:25 +0200
Wed, Dec 28, 2005 at 10:36:40, js (John Smith) wrote about "Casting between 64bit and 32bit":
JS> To my surprise it turned out unsigned long is 64 bit under linux x86_64
JS> where I assumed it was 32 bit as Windows. I guess 64 bit Windows and Linux
JS> does not use the same 64 bit model. This caused lots of problem which needed
JS> to be fixed.
Yes, difference between Unix (most flavors) and MS Windows on x86-64
(a.k.a. amd64) in type sizes is that Windows has 32-bit long, but
Unix has 64-bit long.
To justify each of this decision one can say Windows tried to keep
maximal compatibility with existing applications, OTOH Unixes has
long tradition to use 64-bit systems and types were aligned to
values the same as for other 64-bit systems (Alpha, Power, Sparc64).
This isn't the only difference; most ABI details differ.
If you want to use fixed-width types for all platforms, use
[u]int32_t and [u]int64_t required by C99.