http://qs321.pair.com?node_id=853361


in reply to Interfacing Perl with C++, using XS, with external files, and using the STL as parameters and return values.

Exceptions? So, my code throws exceptions. I cannot catch them, they cause Perl to blow up.

FWIW: In my version of Devel::Size.xs, I catch exceptions. The method I use works for MSVC & gcc on both 32 & 64-bit.

Whether it is compatible with C++ I don't know.

  • Comment on Re: Interfacing Perl with C++, using XS, with external files, and using the STL as parameters and return values.

Replies are listed 'Best First'.
Re^2: Interfacing Perl with C++, using XS, with external files, and using the STL as parameters and return values.
by dextius (Monk) on Aug 06, 2010 at 13:50 UTC
    Wow. I love Devel::Size, I've used that module to test production code many times. Thank you so much for such a useful module. I'm pretty sure my approach is incompatible with exceptions, as I do all my work in the typemap, and I use the XS to directly map to my target function. What I "should" be doing is creating an insulating class, that can catch the exception at the XS layer, and then rethrowing the perl exception from there. This is basically what you are doing in your code. I still think this is unfortunate. You'd think there would be some handy macro that would handle this sort of thing for you.
      Wow. I love Devel::Size, I've used that module to test production code many times. Thank you so much for such a useful module.

      The qudos for Devel::Size firmly belongs to the original author, Dan Sugalski. I just tweaked it a bit to make it a little faster, more reliable and use less memory.