[Haskell-cafe] FunPtr to C function with #arguments determined at runtime?

Krzysztof Skrzętnicki gtener at gmail.com
Sun Feb 17 13:04:14 CET 2013


Hi,

I think libffi might be the answer here. Please see Hackage and Haskell
wiki for details.

Cheers,
Krzysztof Skrzetnicki
17-02-2013 12:18, "Ryan Newton" <rrnewton at gmail.com> napisał(a):

> Hello cafe,
>
> I've been poking around and I haven't seen this addressed anywhere except
> obliquely in the end of section 8.5.1 of the report, where it says that
> variable argument C functions aren't supported:
>
>    http://www.haskell.org/onlinereport/haskell2010/haskellch8.html
>
> The scenario is pretty simple.  I generate C code at runtime.  I compile
> it to a .so.  I know how many arguments it expects (but only at runtime),
> and I get a FunPtr back from 'dlsym'.  How do I call it?
>
> I was hoping there would be some "Raw" lower level FFI layer that I could
> use to invoke a C function without automagic marshaling and all the other
> goodness provided by the normal "foreign import" mechanism.
>
> Failing that, will I just have to generate complex wrappers on the C side
> which I call N times to load up N arguments into some stateful container
> before finally launching the function?
>
> Thanks,
>    -Ryan
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130217/5bb8b0e5/attachment.htm>


More information about the Haskell-Cafe mailing list