# The following was supposedly scribed by # Sisyphus # on Monday 13 September 2004 10:47 pm:
void call_me_stupid(int a, int b) { Inline_Stack_Vars; Inline_Stack_Reset; Inline_Stack_Push(sv_2mortal(newSViv(a))); Inline_Stack_Push(sv_2mortal(newSViv(b))); Inline_Stack_Done; perl_call_pv("main::me_stupid", G_DISCARD); Inline_Stack_Void; }
The above code is pretty much stolen straight out of the Inline::C-Cookbook.
void call_me_stupid(int a, int b) { perl_call_pv("main::me_stupid", G_DISCARD); }
That works for me running 5.8.4 on Linux (even without the loop.)
Yep - same here. It's interesting that works - I would never have thought of even trying it. Unfortunately it still fails (segfaults on the third iteration) when I use it in the actual real-life code. With the "real-life" code the callback-to-perl function is being called from a C function, whereas in the example I provided, it's being called from perl. I'm not sure if that accounts for the different behaviour.
It may also be that I should be approaching this differently - eg pushing values into a global array (which I don't know how to do) rather than sending them back to perl via a callback.
Thanks Eric.
Cheers, Rob
