3 ms·
I don't know haskell, but I would have expected the c++ end to have been compiled with C linkage, why do you have to have the second jump?
by GFK_of_xmaspast 12y ago
I don't know haskell, but I would have expected the c++ end to have been compiled with C linkage, why do you have to have the second jump?
- implicit 12y agoI worked with Chad to write BufferBuilder. We conspired our use of C++ to exclude the C++ standard library. It's basically C with stricter pointer conversion rules.
- chadaustin 12y agoI think falcolas is saying that, since the GHC FFI only supports C functions, if you wanted to expose a C++ API (classes et al) you'd need to have a C trampoline call into C++. But, then again, the compiler might inline the C++ call into the exported C function. Hard to say without trying and looking.
- falcolas 12y agoIt would depend entirely upon whether you wrote all of the C++ code and thus provided yourself with C wrappers inside an `extern c` call. In which case, yes, it would be simpler (though still with an interpreter layer going from C to C++). However, if you use an external library, or you are interfacing with C++ overloaded methods or classes, you have to write an interface inside the `extern c` wrapper which handles calling out to C++ code. Of course, there is always the option of running something like swig to create the C bindings for you.