in reply to Re: Perl API with C
in thread Perl API with C

Thanks kvale, but I don't want to embed anything, I just want to use Perl API's C functions within a C program (if it's possible). :))

Replies are listed 'Best First'.
Re: Re: Re: Perl API with C
by tilly (Archbishop) on Apr 17, 2004 at 20:58 UTC
    Au contraire. You do want to embed something - a Perl interpreter!

    The Perl API is an interface between C and a Perl interpreter. For instance when you try to create a newAV, you needs to AvALLOC it, which allocation assumes that some memory arenas have already been initialized and exist so that you have somewhere to allocate the basic data structure. Which is something that a Perl interpreter does when you start it up. Without a Perl interpreter you are going to do something silly like trying to follow an unitialized value of PL_sv_root and crash after following a null pointer.

    So you can either figure out everything that a Perl interpreter initializes coming into existence (which is basically constructing a Perl interpreter by hand, and WILL break between releases of Perl), or else you can create a Perl interpreter.

    Now hie thee to perlembed as suggested. And note that the first section is about who needs to read perlembed. Given what you are doing, it is appropriate for you.

      Hmmmm... Thanks! Will do!