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.
Sometimes there is such a way. See below.
Details:
I have something like
====================
typedef struct vect {
float x,y;
} vect;
void func(vect v);
For most architectures stack layout of
void func(vect v);
and
void func(float x, float y);
is exactly the same, so for FFI purposes this 'func' can be declared as
something like:
foreign import ccall unsafe :: Float -> Float -> IO ()
Cheers,
Kyra
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe