Why does sizeOf Word64 = 4?
MartinNorbäck
d95mback at dtek.chalmers.se
Sun Nov 9 08:27:08 EST 2003
sön 2003-11-09 klockan 03.32 skrev Ben Escoto:
> Hi, I'm trying to learn about Haskell's FFI (running 6.0.1 on linux)
> and see the following weird behavior with ghci:
>
> Prelude> :module Data.Word Foreign.Storable Foreign.Ptr
> Prelude Foreign.Ptr Foreign.Storable Data.Word> sizeOf nullPtr
> 4
> Prelude Foreign.Ptr Foreign.Storable Data.Word> sizeOf
> (nullPtr :: Ptr Word64)
> 4
>
> Shouldn't "sizeOf nullPtr" return an error? And sizeOf a Ptr Word64
> should be 8 I think.
The size of a pointer is not the same as the size of what it points at.
On ia32 (x86) architectures, the size of a pointer is always 4 bytes (32
bits).
Regards,
Martin
More information about the Glasgow-haskell-users
mailing list