On Tue, Jul 13, 2004 at 03:06:11PM +1000 Sisyphus wrote: > 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 ?
I'd say that you can't simply because PerlIOs are not (necessarily) the same as C's FILE*. Perl does its own flushing when appropriate. > 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. After a call to this function, you could do a fflush(stdin); in your XSUB or so. Tassilo -- $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval