I want to generate C wrappers from C++ libraries. There are tutorials on how to do it by hand:
But it is too much of a manual labor.
For example, for this:
struct RtAudio { virtual DeviceInfo const& f() {...} class DeviceInfo { virtual void g() { ... } }; ... };
I need to write:
struct RtAudioC { RtAudio x; }; struct DeviceInfo { RtAudio::DeviceInfo x; }; extern "C" { RtAudioC* newRtAudio() { return new RtAudioC; } void deleteRtAudio(RtAudioC *p { delete p; } /* do something with RtAudio::f() */ void g(DeviceInfo *p) { try { p->x.g(); } catch (SomeError & err) { } } }
Are there tools that can automate this process?
You can try SWIG, C code generator was last year's GSoC project. AFAIK they haven't merged it to the trunk yet, so you'd have to checkout & build the branch from SVN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With