Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
Today I've started to study perlembed, Here is the first code example in Perlembed:
Ican build it successfully, and it works as expected.(windows 10, strawberry perl 5.32) But if I change interpreter variable name to his_perl, it doesn't work!#include <EXTERN.h> /* from the Perl distribution */ #include <perl.h> /* from the Perl distribution * +/ static PerlInterpreter *my_perl; /*** The Perl interpreter *** +/ int main(int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); my_perl = perl_alloc(); perl_construct(my_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(my_perl, NULL, argc, argv, (char **)NULL); perl_run(my_perl); perl_destruct(my_perl); perl_free(my_perl); PERL_SYS_TERM(); exit(EXIT_SUCCESS); }
It can't be build, and complains identifier "my_perl" is undefined. I notice in perl.h aTHX hard code define to my_perl, I guess that is the reason why his_perl version can't be built. But why is this name(my_perl) so important, that it should write it into perl.h? Please enlighten me.#include <EXTERN.h> #include <perl.h> static PerlInterpreter *his_perl ; /*** The Perl interpreter * +**/ int main(int argc, char **argv, char **env) { PERL_SYS_INIT3(&argc,&argv,&env); PERL_SYS_TERM(); his_perl = perl_alloc(); perl_construct(his_perl); PL_exit_flags |= PERL_EXIT_DESTRUCT_END; perl_parse(his_perl, NULL, argc, argv, (char **)NULL); perl_run(his_perl); perl_destruct(his_perl); perl_free(his_perl); exit(EXIT_SUCCESS); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl interpreter must be named my_perl?
by Corion (Patriarch) on Nov 30, 2023 at 08:03 UTC | |
by Anonymous Monk on Nov 30, 2023 at 08:56 UTC | |
by Corion (Patriarch) on Nov 30, 2023 at 09:05 UTC | |
by ikegami (Patriarch) on Dec 01, 2023 at 03:49 UTC | |
by Anonymous Monk on Dec 01, 2023 at 05:33 UTC | |
|