in reply to Perlembed: problem with exception
It outputs:use warnings; use Inline C => Config => BUILD_NOISY => 1; sub register_vm { die "register_vm() has died"; } use Inline C => <<'EOC'; SV * foo(char * config) { int bRet = 1; STRLEN n_a; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(newSVpv(config, 0))); PUTBACK; perl_call_pv("register_vm", G_DISCARD|G_EVAL); SPAGAIN; if(SvTRUE(ERRSV)) { printf ("From C: %s\n", SvPV(ERRSV, n_a)); bRet = 0; } PUTBACK; FREETMPS; LEAVE; return newSViv(bRet); } EOC $ret = foo('arg'); print "Perl's \$\@ contains: $@\n\$ret: $ret\n";
Not quite sure what your original aim was. Hopefully, with the help of 'perldoc perlapi' and the other docs I've already mentioned, you can work out how to modify that script to suit your needs. If not, post again.From C: register_vm() has died at try.pl line 5. Perl's $@ contains: register_vm() has died at try.pl line 5. $ret: 0
|
|---|