Hi,
The following test script works fine, and simply outputs '3 5'.
----------------------------------------- use warnings; use Inline C => <<'EOC';
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; }
EOC
#for(1..4) { #print "$_: "; call_me_stupid(3, 5); #}
sub me_stupid { print "$_[0] $_[1]\n"; }
__END__
But if I alter the above perl code by removing the 3 '#'s, then I get the following output:
1: 1 4
2:
3:
4:
That's on Win2000, perl 5.6.1. On perl 5.8.4 the blank lines of output are replaced with a warning about "uninitialised value".
What on Earth is happening ? Note that an error occurs with the very first iteration.
The C code that Inline generates can be found below my sig.
Cheers, Rob
#line 1 "stupid_pl_6bb4.xs" #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "INLINE.h"
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; }
#ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(var) if (0) var = var #endif
#line 32 "stupid_pl_6bb4.c" XS(XS_main_call_me_stupid); /* prototype to pass -Wmissing-prototypes */ XS(XS_main_call_me_stupid) { dXSARGS; if (items != 2) Perl_croak(aTHX_ "Usage: main::call_me_stupid(a, b)"); PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(ax); /* -Wall */ SP -= items; { int a = (int)SvIV(ST(0)); int b = (int)SvIV(ST(1)); #line 28 "stupid_pl_6bb4.xs" I32* temp; #line 47 "stupid_pl_6bb4.c" #line 30 "stupid_pl_6bb4.xs" temp = PL_markstack_ptr++; call_me_stupid(a, b); if (PL_markstack_ptr != temp) { /* truly void, because dXSARGS not invoked */ PL_markstack_ptr = temp; XSRETURN_EMPTY; /* return empty stack */ } /* must have used dXSARGS; list context implied */ return; /* assume stack size is correct */ #line 58 "stupid_pl_6bb4.c" PUTBACK; return; } }
#ifdef __cplusplus extern "C" #endif XS(boot_stupid_pl_6bb4); /* prototype to pass -Wmissing-prototypes */ XS(boot_stupid_pl_6bb4) { dXSARGS; char* file = __FILE__;
PERL_UNUSED_VAR(cv); /* -W */ PERL_UNUSED_VAR(items); /* -W */ XS_VERSION_BOOTCHECK ;
newXS("main::call_me_stupid", XS_main_call_me_stupid, file); XSRETURN_YES; }