what do PERL_SYS_INIT3() and PERL_SYS_TERM() do?by xiaoyafeng (Chaplain)
|on Dec 30, 2011 at 21:21 UTC||Need Help??|
xiaoyafeng has asked for the
wisdom of the Perl Monks concerning the following question:
I've tried to embed perl into a winform program written in C++/CLI recently. but got stuck with an conflict between managed style main function and PERL_SYS_INIT3 macro. the issue is compiler always complain if I put PERL_SYS_INIT3 into managed main body.(of course, it can't find any argc,argv adress in CLI). However what make me surprised， if I comment it everything seems OK. I mean, program could be compiled, and run correctly. Below is partial codes:
here is said in perl api:The macros PERL_SYS_INIT3() and PERL_SYS_TERM() provide system-specific tune up of the C runtime environment necessary to run Perl interpreters; they should only be called once regardless of how many interpreters you create or destroy. Call PERL_SYS_INIT3() before you create your first interpreter, and PERL_SYS_TERM() after you free your last interpreter. So what these 2 macros do behind? it does tune up? will it bring some issues when I comments it?
thanks in advance!
In addition, perl_destruct(my_perl) can't be uncommented too,otherwise it will throw:
thank patcat88, it's like that PERL_SYS_INIT3 JUST run InitializeCriticalSection (&(*Perl_Gperlio_mutex_ptr (0))); So I pass NULL to it and by far everything seems ok. I'll do more tests.
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction