struct and tuples

Axel Jantsch axel at kth.se
Wed Jun 21 10:29:46 EDT 2006


Hi,

I thought I wanted something very simple but just cannot find out how to do it;
I assume I am overlooking something very obvious.

I want to hand over a tuple to a C function and get a tuple back:

  type myTup = (Bool, Int)
  myFun :: myTup -> myTup

So myFun should be implemented as a C function and I thought I use a struct to 
represent the tuple:

  typedef struct myStruct { int b; int x; };
  struct myStruct myCFun (struct myStruct);


I tried to use c2hs, looked at the documentation of ffi, c2hs, greenCard, hsc2h
s, 
the mail archives etc. but I somehow I cannot figure out how to do it.
Do I have to use Ptr? Do I have to make myTup an instance of Storable? Or?

I greatly appreciate any hint!
-- Axel

-- 
Phone: +46 8 790 4124, Email: axel at kth.se, Web: www.it.kth.se/~axel


More information about the FFI mailing list