Sisyphus <[EMAIL PROTECTED]> writes:
But should I instead be using the "Perl abstraction layer" as mentioned in 'perclib' ? I often end up with segfaults when I try messing with the Perl abstraction layer. In fact, that's exactly what I get when I replace the 'fflush(stdout);' with a
PerlIO_flush(PerlIO_stdout());
Is that what perlclib is saying I should do ?
I don't know what that file says but that is what you should do.
Hmmm ... but it's not working. (Sorry, I thought it was giving me a segfault, but that's not so - it compiles without warning, but simply doesn't alter the output I was getting.)
Here's that script as it now stands:
use warnings;
use Inline (C => Config => BUILD_NOISY => 1, );
use Inline C => <<'EOC';
void func_1() { printf("SOMETHING"); PerlIO_flush(PerlIO_stdout()); }
void func_2() { printf("something\n"); }
EOC
print "1\n"; func_1(); print "\n2\n"; func_2; print "3\n";
__END__
I've turned on 'BUILD_NOISY' so that I can see any warnings issued during the compilation phase (and there are none). But I'm still getting the same (garbled) output:
1
2 SOMETHINGsomething 3
I get the desired output, however, if I replace: PerlIO_flush(PerlIO_stdout()); with: fflush(stdout);
Output then becomes:
1 SOMETHING 2 something 3
It's not supposed to be like that, right ? Or perhaps there are some "ifs and buts" that need to be considered ... Or I am being exceedingly dense ... yet again.
Cheers, Rob