strcpy(error, SvPV(ERRSV, PL_na));

Looks like you're trying to copy into the 'error' variable what is already in $@. You want to use sv_setpv instead of strcpy - see 'perldoc perlclib'.

Here's a simplified Inline C example that works fine for me.
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";
It outputs:
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
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.

Cheers,
Rob

In reply to Re: Perlembed: problem with exception by syphilis
in thread Perlembed: problem with exception by Arlekin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.