I'm trying to connect perl and C together. I know how to call perl from C code, by creating a new PerlInterpreter.
I've also played with calling C from perl code, by creating xsubs.
But what I really want to do is call perl from C, and then
from that perl, call functions back in the original C, but
more importantly I need to make this a library that I can link in with a C program.
In other words, I need to be able to do something like this:
C CODE:
int some_Cvar; // Global to C
int main (void) {
call_perl("some_perl_func");
printf("C: some_Cvar = %d\n",some_Cvar);
}
int set_some_Cvar (int val) {
some_Cvar = val;
}
-------------------------
PERL CODE:
sub some_perl_func {
print "In perl - setting some_Cvar\n";
set_some_Cvar(42);
}
And most importantly I need to be able to do it as a library, since I'm linking it with a program that I don't have the source for... (don't ask :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.