gszczesz has asked for the wisdom of the Perl Monks concerning the following question:

Anyone know how to get compilation errors in Perl code snippets when embedding perl code in C?? The SV ERRSV doesn't seem to contain compilation errors after I ran eval_pv...
eg, in C++: SV* result = eval_pv( code.c_str(), TRUE); if( SvTRUE(ERRSV) ) { // Print out errors }
The ERRSV doesn't seem to output compilation errors in the code string.... I'm using perl5.8.9. Perl 5.10.0 had problems with ERRSV always being NULL. Greg

Replies are listed 'Best First'.
Re: perlapi - How to get compilation errors SV
by almut (Canon) on Apr 10, 2009 at 22:05 UTC

    Maybe you could try eval_sv instead, which (in contrast to eval_pv) allows the G_KEEPERR flag to be specified (you wouldn't get your SV result, though...).  Something like this (untested):

    eval_sv(newSVpv(code.c_str(), 0), G_KEEPERR);

    See also this thread and G_KEEPERR.

      That did the trick. Forever in your debt. Greg