[columbus.pm] very basic embedding of perl into c++
Ron Grabowski
ronnie at catlover.com
Sat Apr 29 09:28:04 CDT 2000
I am very inexperienced when it comes to c/c++. I've read chapter 19 of
Programming Perl and that still didn't make a lot of sense to me. I want
to embed a couple subroutines, call them, and send the returned string
back to C. I have several subroutines so 'perl_eval_va()' isn't the best
choice.
rons_program.pl
---------------
sub HI {
GOODBYE();
}
sub GOODBYE {
return "see you later";
}
$var = HI();
__END__
I _think_ this code might be close to what I want:
Example 19.2: ex.c: Embedding Perl
#include <EXTERN.h>
#include <perl.h>
static PerlInterpreter *my_perl;
main(int argc, char **argv, char **env) {
my_perl = perl_alloc();
perl_construct(my_perl);
/* what does this do ? */
perl_parse(my_perl, NULL, argc, argv, env);
/* this is wrong becuase I don't want my
output discarded */
perl_call_argv("rons_program", G_DISCARD);
perl_destruct(my_perl);
perl_free(my_perl);
}
But I want to capture the returned value as some sort of string...
When compiling it,
% gcc -o ex -I/usr/local/lib/perl5/i586-linux/5.004/CORE \
-L/usr/local/lib/perl5/i586-linux/5.004/CORE \
-Dbool=char -DHAS_BOOL \
ex.c -lperl -lm
What are the '-Dbool=char' and '-DHAS_BOOL' flag?
- Ron
-----------------------------------------------------------------------
To send mail to the Columbus.pm list send email to
columbus-pm-list at happyfunball.pm.org
To unsubscribe send an email to majordomo at hfb.pm.org with
unsubscribe columbus-pm-list youremail at yourdomain.com
-----------------------------------------------------------------------
More information about the Columbus-pm
mailing list