
Felipe Lessa wrote:
Hi,
I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and while I can live without it, I'd like to leave no doubt.
You might find this old post of mine useful. http://therning.org/magnus/archives/315
Details:
I have something like
==================== typedef struct vect { float x,y; } vect;
void func(vect v); =====================
on the C side and
==================== -- Please disregard float /= Float, just an example :) data Vector = Vector Float Float
instance Storable Vector where ... ====================
on the Haskell side, and I want to call func with Vector as argument. Now, Vector isn't a basic FFI type, although it implements Storable. So does that mean that I need to create something like
==================== void funcWrapper(vect *v) { func(*v); } ====================
and then allocate some temporary memory on the Haskell side to use func?
Cheers!
-- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus Haskell is an even 'redder' pill than Lisp or Scheme. -- PaulPotts