xsubpp can generate exception handling code for c/c++ files converted from .xs files. It generates the following piece of code for me
TRY {
char * CLASS = (char *)SvPV_nolen(ST(0));
Example * RETVAL;
RETVAL = new Example();
ST(0) = sv_newmortal();
sv_setref_pv( ST(0), CLASS, (void*)RETVAL );
}
BEGHANDLERS
CATCHALL
sprintf(errbuf, "%s: %s\tpropagated", Xname, Xreason);
ENDHANDLERS
But when compiling the generated code, I'm getting compilation errors as TRY, BEGHANDLERS, CATCHALL, ENDHANDLERS were not defined anywhere in perl header files. I've modified my code to define the above mentioned tokens like this.
#define TRY try
#define BEGHANDLERS
#define CATCHALL catch (...) {
#define ENDHANDLERS }
But I'm not able to give meaningful definitions to Xname and Xreason. Are the above definitions correct ? How do we handle the above mentioned keywords