[cffi-devel] C++ Exceptions.

James Bielman jamesjb at jamesjb.com
Tue Feb 13 04:27:12 UTC 2007


On Mon, 2007-02-12 at 16:44 +0000, Luís Oliveira wrote:
> On 12/02/07, Collin Lynch <collinl at cs.pitt.edu> wrote:
> > In any case, is there any way to catch the underlying c++ exceptions
> > within a cffi-wrapper?  I have developed a C++ library that defines its
> > own exceptions and I would like to trap them and generate an appropriate
> > Lisp Condition.  At present deliberately triggering an error (say by
> > passing incorrect parameters to a constructor) gives me back a null
> > pointer.
> 
> C++ support would be nice. I don't personally have a need for it, but
> it would be nice. Patches are welcome! :-)

Personally, I consider C++ so deliberately hostile to interfacing
with other languages that I'm not sure I'd even want to be responsible
for maintaining code for binding to C++ libraries.

As I understand it, there's not even a platform ABI that one can try to 
conform to---things like C++ exception handling and name mangling
differ not only per-compiler, but vary depending on the version of
the compiler being used.  (ISTR maybe they did this for amd64?  But
I don't think there is in the general case...)

> Otherwise, you can handle exceptions and other C++ stuff by writing
> some C glue and calling that with CFFI.

Unfortunately I think this is the most sane way to go at this point.

I suppose another option would be some kind of standard network
object protocol like CORBA, but that's a whole separate mess...

James





More information about the cffi-devel mailing list