
24 Jul
2002
24 Jul
'02
8:20 a.m.
Nick Name wrote:
[...] Is there a way? I really don't know anything about calling C++ from C. Is there some way to make haskell bindings for a C++ library? Am I stuck in a dead end? Already?
The current FFI doesn't support C++, nevertheless there is a slightly tedious, but doable way around this: Write a thin wrapper with C linkage around the C++ stuff, using your favourite C++ compiler, e.g. extern "C" double foo(int x) { ... } is callable via the normal foreign import ccall foo :: CDouble -> CInt (add "unsafe" or IO, depending on the nature of foo). Cheers, S.