[columbus.pm] very basic embedding of perl into c++
Colin Walters
levanti at verbum.org
Sat Apr 29 12:14:52 CDT 2000
>>>>> "Ron" == Ron Grabowski <ronnie at catlover.com> writes:
Ron> I want to embed a couple subroutines, call them, and send the
Ron> returned string back to C. I have several subroutines so
Ron> 'perl_eval_va()' isn't the best choice.
One of the first things you will learn when embedding Perl is that
perl is not very embedding-friendly :)
[code snipped]
Ron> [...] But I want to capture the returned value as some sort
Ron> of string...
Yes. That's why you have to call the subroutine by hand. See Chapter
20, "Calling a Perl Subroutine", page 352.
In particular, you have to use POPp to get the returned string from
the stack after calling perl_call_pv().
Ron> When compiling it,
Ron> % gcc -o ex -I/usr/local/lib/perl5/i586-linux/5.004/CORE \
Ron> -L/usr/local/lib/perl5/i586-linux/5.004/CORE \ -Dbool=char
Ron> -DHAS_BOOL \ ex.c -lperl -lm
Ron> What are the '-Dbool=char' and '-DHAS_BOOL' flag?
If the perl source needs a boolean value, this tells it to use a
'char' type. No big deal.
-----------------------------------------------------------------------
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