I am trying to call perl subroutines from within C and have read 'Perlcall' and 'PerlEmbed' (which did confuse me a little). I would really appreciate it if anyone with more experience could possibly help me with the following questions?
1. I have tried a (very simple) test to call a perl function (hi::say_hi) which is installed as a perl module on my system. Unfortunately, I know I've misunderstood something and I just can't get it to run even after RTFM. Could someone point out what I've done wrong please?
*****C Function - test.exe***** #include <stdio.h> #include <EXTERN.h> #include <perl.h>
static PerlInterpreter *my_perl;
int main( void ) { printf( "This program invokes a Perl Script\n" );
dSP; PUSHMARK(SP); //Perl Call call_pv("hi::say_hi", G_DISCARD | G_NOARGS);
return 0; }
*****Perl Function***** package hi;
use strict;
...
#Function to be called from C sub say_hi { print "Hello from Perl"; }
As for the IDE, I'm using VisualStudio.NET and have included perl56.lib as per the Perlembed instructions. The C compiles correctly, but when running, I see the following error as soon as the "dSP;" macro is run:
"An unhandled exception of type 'System.NullReferenceException' occurred in test.exe
Additional information: Object reference not set to an instance of an object."
What am I doing wrong?
2. To call a perl sub, does the sub have to be installed as a package or can it be a simple script file (eg .pl file) ?
3. I don't know much about PerlXS. Do I need to create an XSUB interface?
Many thanks to anyone who replies. Regards,
James.
_______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs