Converting [Word8] to CString

Ashley Yakeley
Sat, 15 Sep 2001 21:39:19 -0700

At 2001-09-15 02:15, Marcin 'Qrczak' Kowalczyk wrote:

>Fri, 14 Sep 2001 23:40:42 -0700, Ashley Yakeley <> pisze:
>> I'm looking for a function that will convert a [Word8] byte-array
>> to a CString (i.e. a C byte array) for the purposes of FFI.
>You can use newArray which allocates the C byte array using malloc
>so it must be freed by free, and cast the resulting pointer from
>Ptr Word8 to CString using castPtr.

Thank you. I ended up doing this and simply using Ptr Word8 as the FFI 

Curiously, the GHC user's guide sec. seems to suggest that Ptr 
types are illegal as arguments in foreign import function declarations. I 
think this is the source of my confusion.

Ashley Yakeley, Seattle WA