
8 Aug
2014
8 Aug
'14
5:51 p.m.
Il giorno 08/ago/2014, alle ore 17:29, Donn Cave
How can I do that? In general, I've only seen example of how to exchange primitive types with C functions through the FFI, but not for example structures or pointers to structures.
Foreign.Storable is the key to packing and unpacking a struct. The hsc2hs utility adds some support for struct member names, which will make your code more convenient and robust. You will also find "peek" and "poke" functions in Foreign.Storable, for pointer access.
Thanks! Is this the approach used by the llvm-general library? Moreover, I see that peek and poke return IO a, so I can't pretend that the interface that I'm wrapping is pure, can I? Nicola