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.


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!

-- 
Felipe.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to