[Haskell-cafe] FFI: Creating a Storable for a C-struct composed
of char arrays
olivier.boudry at gmail.com
Fri May 9 10:28:38 EDT 2008
Thanks for your help, CString will work great for Char arrays, but what
about the 16bit-Word arrays? I was not clear in my previous post but the
structures used in the nwrfcsdk library can use 8bit or 16 bit "chars"
depending on a #define (#define SAPwithUNICODE).
Reading another post on FFI in this mailing list I found a link to the
following page http://haskell.org/haskellwiki/Modern_array_libraries with a
section on StorableArrayS. I'm now trying to use this example code to get
StorableArray to work.
I will try to use Data.Encoding to convert Haskell StringS to ASCII or UTF16
ByteStringS. Then unpack those ByteStringS to Word8 list and populate
StorableArrayS with the bytes. I hope it'll do the job for both Word8 and
On Fri, May 9, 2008 at 9:52 AM, Brandon S. Allbery KF8NH <
allbery at ece.cmu.edu> wrote:
> On 2008 May 9, at 9:42, Olivier Boudry wrote:
> Of course it won't work as HArrayStruct in file HArrayStruct.hs uses
> Strings and String is not an instance of Storable.
> Ideally I would need some sort of Storable array of char. Is
> Data.Storable.Array the type I'm looking for? Could someone point me to some
> code using the same kind of structures?
> You want CString (Foreign.C.String).
> brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
> system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
> electrical and computer engineering, carnegie mellon university KF8NH
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe