.... somewhere in big C program
void call_perl(void) { /* call perl function to do the work and trap any errors */ /* use the static (singleton) version of the perl interpreter */ my_perl = get_perl("module_init.pm");
based on SWIGs' perlmain.i
PerlInterpreter* get_perl(char *perl_file) { int exitstatus; /* have we done this? */ if (NULL != my_perl) { return my_perl; } char *my_argv[] = { "", perl_file }; my_perl = perl_alloc(); if (!my_perl) exit(1); perl_construct( my_perl ); exitstatus = perl_parse( my_perl, xs_init, 2, my_argv, (char **) N +ULL ); if (exitstatus) exit( exitstatus ); /* Initialize all of the module variables */ /* exitstatus = perl_run( my_perl ); */ return my_perl; }
back to call_perl
perl_call_pv("module::sub", G_EVAL|G_DISCARD|G_NOARGS|G_VOID) ;
So far so good. I am now happily in perl land. next:
c_exe::c_function($self->{value},$self->{channel});
This fails. What should happen is the call gets routed through this bit of SWIG generated perl code
package c_exe; *c_function = *c_exec::c_function;
to this c file: c_exe_wrap.c
XS(_wrap_c_function) { { BOW_USHORT arg1 ; BOW_UCHAR *arg2 = (BOW_UCHAR *) 0 ; unsigned short val1 ; int ecode1 = 0 ; int res2 ; char *buf2 = 0 ; int alloc2 = 0 ; int argvi = 0; BOW_SHORT result; dXSARGS; ... a bunch of code to validate parameters ... result = c_function(arg1,arg2); ... a bunch of code to handle return ... } }
But what I get is something like:
function c_exe::c_function not found at...

In reply to Re^2: C calling perl calling C by uwc
in thread C calling perl calling C by uwc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.