tags:

views:

60

answers:

2

Hi, I am new to swig,using swig for integrating c++ code to Perl,I have c++ function like void s() throw MyException. How i can integrate the c++ function that can throw the MyException in the swig interface file.How i can called the c++ function in Perl. Any Help in this regard is highly appreciated.

+1  A: 

Here's a link that involves Python. Here's the links to exceptions with C++ from the Swig website. Here's a link to exception handling.

Basically you're going to need to set up your *.i file to tell the Perl code how to handle the exceptions. There's good documentation on the Swig website. I'm sorry I can't be of more help. I don't know Perl and have no experience with Swig and Perl. I'm also having problems with Swig and exceptions.

wheaties
+2  A: 

If you're not entirely set on using swig for wrapping your C++, then maybe have a look at the exception handling code I wrote for the ExtUtils::XSpp tool.

It quite conveniently converts C++ exceptions to Perl exceptions by default. For more fine-grained control, you can declare your exception types to the wrapper and specify how they are supposed to be treated.

tsee