Re: Hugs ffi, sizeOf operator

Ross Paterson <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
On Mon, Jan 06, 2003 at 03:42:27PM -0500, R. Legere wrote:
> I ran into a possible problem while testing some ffi code.
>  This is with hugs compiled for cygwin or with the windows (msi)  version.
> Hugs says: sizeOf x::CDouble is 4,
> wheras 'C' says sizeof(double) is 8.
> 
> I ~~think~~ I see what the problem is with sizeOf.  I am using the
> new hierarchical libs, and it defines sizeOf by hardcoding the sizes rather
> then asking 'c' like the previous versions did. And sizeOf Double is coded
> as 4 in libraries\Foreign\Storable.hs

Thanks for the report.  It's a bug on all architectures, now fixed in CVS.
(The sizes are computed in the configuration process, and there was some
confusion about doubles.)  A workaround is to change that 4 to an 8.

> As a side note, is alignPtr implemented somewhere?

Not in the Nov 2002 release.  The CVS version has

alignPtr :: Ptr a -> Int -> Ptr a
alignPtr p n = p `plusPtr` ((n - ptrToInt p `mod` n) `mod` n)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.