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

Ryan Newton rrnewton at gmail.com
Sun Feb 17 12:16:33 CET 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130217/7e0f5781/attachment.htm>


More information about the Haskell-Cafe mailing list