DrMoisha has asked for the wisdom of the Perl Monks concerning the following question:
I'm now trying to call perl functions from c code. I've already built perl with MSVS2013 Professional on Windows 7 64 bit. I'm now testing perlembed code, and I've run into problem.
Let's look at Calling a Perl subroutine from your C program.
My trouble is if I call some sub, it only actually executes on perl_destruct(my_perl);. I did not found what causes such behaviour in perlembed. And I don't quite understand what is happening, so I tried place perl_run(my_perl), or GL_EVAL in different places.#include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; int main(int argc, char **argv, char **env) { char *args[] = { NULL }; PERL_SYS_INIT3(&argc,&argv,&env); my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, NULL, argc, argv, NULL); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; /*** skipping perl_run() ***/ call_argv("showtime", G_DISCARD | G_NOARGS, args); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); }
Okay,- I've thought,- let's try Maintaining a persistent interpreter example. I don't want to bloat my question so here is link Maintaining-a-persistent-interpreter-example
This example crashes here:
When I comment this out, it still does nothing, even on perl_destruct();if(SvTRUE(ERRSV)) fprintf(stderr, "eval error: %s\n", SvPV_nolen(ERRSV));
So my first question: is there any manual for me to understand, what happens when call_argv() is called? I'm now reading perlguts, perlcall, however, I cannot find it. If you can, please specify me right way.:)
And second question: when call_argv(); actually executes function? Or can I force somehow to do it? Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: When call_argv() actualy executes function
by syphilis (Archbishop) on Mar 31, 2015 at 13:12 UTC | |
by DrMoisha (Novice) on Mar 31, 2015 at 14:16 UTC | |
|
Re: When call_argv() actualy executes function
by Corion (Patriarch) on Mar 31, 2015 at 12:41 UTC | |
by DrMoisha (Novice) on Mar 31, 2015 at 14:12 UTC |