This is example I'm looking at https://metacpan.org/pod/perlembed#Fiddling-with-the-Perl-stack-from-your-C-program and I think you could copy this example and turn it into void callback(),
something like
// static void PerlPower(int a, int b) static void callback() { dSP; /* initialize stack pointer */ ENTER; /* everything created after here */ SAVETMPS; /* ...is a temporary variable. */ PUSHMARK(SP); /* remember the stack pointer */ XPUSHs(sv_2mortal(newSViv(a))); /* push the base onto the stack */ XPUSHs(sv_2mortal(newSViv(b))); /* push the exponent onto stack */ PUTBACK; /* make local stack pointer global */ // call_pv("expo", G_SCALAR|G_DISCARD|G_NOARGS); /* call the fu +nction */ call_pv("p_callback", G_DISCARD|G_NOARGS); SPAGAIN; /* refresh stack pointer */ /* pop the return value from stack */ // printf ("%d to the %dth power is %d.\n", a, b, POPi); PUTBACK; FREETMPS; /* free that return value */ LEAVE; /* ...and the XPUSHed "mortal" args.*/ }
Yes , I understand perlcall gives simpler example like you have , but its what I would try, to see if anything sticks :D
In reply to Re^3: XS: Passing an external library's function a Perl XS callback
by Anonymous Monk
in thread SOLVED: XS: Passing an external library's function a Perl XS callback
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |