I have recently converted a library, I originally wrote in C++ with Boost Python wrapping, to C with SWIG wrapping to support more languages.
I switched from C++ to C because the library consists only of a set of functions and I also want the library to be callable from C (without having to compile the whole program with a C++ compiler).
However there is one thing that was not easy to port, a very small subset of the functions needs the ability to report errors back.
In C++/Boost Python that was very elegantly accomplished with throw and exception translation.
What would be the most elegant way (on both the C and wrapped language side) to have a subset of functions report errors?
Take a look at Chapter 4 in C Interfaces and Implementations by Richard R. Hanson.
Most elegant way for SWIG wrapped C library to raise exceptions