When you mostly want to call C code from perl it's easiest to build a perl module with XS code and use that module like you would any other perl module. XS code is basically C code with a whole lot of macros and extra syntax to make it easy to talk to the perl interpreter and to make it easy to "export" C functions to perl (so they can be called like any other perl function).
See perlxstut for starters. Because XS code is mostly C, you would have to include any header files you'd normally need to include in a C program plus the header files that XS/perl needs. You would also have to make sure your code is linked to any libraries/objects you need just like regular C (though perl's ExtUtils::MakeMaker can make it reasonably easy to do so portably).
If your setup really works the other way around (i.e. you're mostly calling into perl from C) you can embed a perl interpreter in your C code and just call perl functions whenever you need them. Apart from how you compile/link your program there isn't really much difference between the two options as far as communicating between the perl and C side of the program is concerned.
See also, perlapi, perlembed, perlcall, perlxs and the Manning book "Extending and Embedding perl".
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.