pony-tutorial
pony-tutorial copied to clipboard
Improve FFI documentation
I added an issue (#83) for wanting a section about callbacks, but maybe that should be in here?
I think that is reasonable for now
Two more for this list
-
FFI functions raising errors talks about how Pony code should declare and handle errors from C but doesn't talk about how the C side should raise an error. We're guessing this is via
pony_error()with notes inponyc/src/libponyrt/pony.hand some examples inponyc/src/libponyrt/lang/time.c,ponyc/src/libponyrt/lang/posix_except.c, andponyc/src/libponyrt/lang/socket.c. -
Linking to C Libraries doesn't mention C++. Maybe another section? I've had some success with this method, happy to discuss. ** Write a C wrapper to manage C++ object storage and method invocations. This wrapper would FFI to Pony as normal. ** Make sure the wrapper functions which need to be seen in Pony FFI are declared
extern "C" { ... }. ** When linking with GNU tools, be sure to useponyc --linker g++because the C++ mangled names and also because of the runtime environment is needed AND be sure to havelibstdc++on your system