On Wed, Feb 29, 2012 at 9:17 PM, Thomas Grill gr@grrrr.org wrote:
Hi Katja, maybe i'm chiming in too late, but i would definitely use C++ programming for whatever i do in the C-world. It's no problem to make the public API (exported functions) C-style then to avoid various hassles. If your library is just a wrapper it might not be worth to live in both worlds, but if it's a substantial amount of code, i would go for C++ with a C interface. gr~~~
Thanks for your recommendation, Thomas. Mathieu and IOhannes did similar suggestions.
Can anyone point me to an example of a C++ lib with C API, in the field of dsp? Not sure if I can think of the best way how to do it.
As I see it now, a C++ class could be instantiated and accessed from C like so:
returns the pointer to the instantiated object.
their first argument, like how you would access data in C structs.
class member functions to access the class private data in C++ style.
How about function call overhead? For constructor and destructor no problem of course, but accessor wrappers will be called often, in fact it doubles the number of function calls for external access.
Katja