[Haskell-cafe] ffi and pass by value structs
federico.squartini at googlemail.com
Wed Jan 30 08:16:01 EST 2008
Is there a way in the foreign function interface to pass to a function
a struct by value? I explain it better.
There are two ways in c to pass structs, as in the following example:
/* begin c code */
int print_couple (struct couple cpl)
int print_couple_ptr (struct couple *cpl)
/* end c code */
Apparently in the ffi it is possible to import the second version, as:
foreign import ccall "print_couple_ptr" printCouple::Ptr Couple->IO Int
But not the first, as a struct it's not an atomic type.
So how does one solve this issue?
More information about the Haskell-Cafe