Hi,
Consider the following Inline C script:
use warnings; use Inline C => <<'EOC';
void func_1() { printf("SOMETHING"); }
void func_2() { printf("something\n"); }
EOC
#$| = 1; #makes no difference
print "1\n"; func_1(); print "\n2\n"; func_2; print "3\n";
__END__
With perl 5.8.4 I would expect that to produce the following output: 1 SOMETHING 2 something 3
And that's exactly what is produced for me on Win32. But on my MDK-9.1 Linux I'm getting:
1
2 SOMETHINGsomething 3
So the question is: How do I get the expected result without altering the C code ?
The actual XS file that Inline generates is included below (if that helps).
Note that the problem is _not_ specific to Inline C. I've simply written it that way for simplicity, hoping that someone else can readily replicate the unusual result and maybe point to a solution. In "real life" I'm dealing with a third party library in a normal XS-build environment - and getting that odd behaviour with a function (within that library) that prints to stdout but doesn't print a newline.
Cheers, Rob
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "INLINE.h"
void func_1() { printf("SOMETHING"); }
void func_2() { printf("something\n"); }
MODULE = try_pl_903a PACKAGE = main
PROTOTYPES: DISABLE
void func_1 () PREINIT: I32* temp; PPCODE: temp = PL_markstack_ptr++; func_1(); 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 */
void func_2 () PREINIT: I32* temp; PPCODE: temp = PL_markstack_ptr++; func_2(); 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 */