How does one use pass by reference functions using the ffi?

Alastair Reid alastair at reid-consulting-uk.ltd.uk
Sun Jan 25 10:04:50 EST 2004


>   Say I have a function somewhere in c land with the following declaration:
>
> void doStuff( int &a, int &b);
>
>   What would the appropriate Haskell wrapper for this function look like?
> I'm looking to construct a haskell function of the type:

The following (untested) Greencard code ought to do the trick.

%fun doStuff :: Int -> Int -> IO (Int,Int)
%code doStuff(&arg1,&arg2)
%return ({*arg1},{*arg2})

--
Alastair Reid



More information about the FFI mailing list