Ashley Yakeley <[EMAIL PROTECTED]> wrote,

> At 2001-09-20 06:55, Manuel M. T. Chakravarty wrote:
> 
> >The FFI does not ensure any type consistency between the
> >arguments to `Ptr'/`ForeignPtr' and the corresponding C
> >types.
> 
> I've been using 'Ptr Word8' with newArray to pass lists of bytes to C 
> functions. They appear as unsigned char arrays in the C function. Is this 
> wrong, or not guaranteed?

It is guaranteed that when you marshal a `[Word8]' into a
`Ptr Word8' with newArray that you get a contiguous memory
area filled with the bytes from the list.  So, what you are
doing is perfectly fine.  

What I meant with the remark that you quote is that if you
would use

  foreign import foo :: Ptr Int -> IO Float

with

  float foo (float *x)
  {
    return *x;
  }

the system will not complain, but your program may dump
core.

Manuel

_______________________________________________
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to