Hi BrowserUK,

I had missed that final post of yours to the thread Inline C: using stderr segfaults?. I think you've got down to a level that I'd like to stay well clear of :-)

Incidentally, as regards *your* thread, did it make any difference if you rewrote test2() to use the perl abstraction layer ?
void test2 ( char* text ) { PerlIO_printf( PerlIO_stderr(), "Got:'%s'\n", text ); }
As you say, the problems that you faced there may well be related to the problems I've been looking at - though I still have this notion that (at least part of) your problem might arise from the involvement of *2* C runtime libraries.

As for my particular issue, the following (somewhat kludgy) workaround seems to work reliably without any need to turn on $| ... though I haven't yet tried it on anything other than Win32:
use warnings; use strict; use Inline C => Config => INC => '-IC:/_32/C', LIBS => '-LC:/_32/C -lmylib', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include <mylib.h> void _foo(PerlIO * stream) { FILE * stdio_stream = PerlIO_exportFILE(stream, NULL); my_puts(stdio_stream); fflush(stdio_stream); PerlIO_releaseFILE(stream, stdio_stream); } void _foo2(PerlIO * stream, SV * suffix) { FILE * stdio_stream = PerlIO_exportFILE(stream, NULL); my_puts(stdio_stream); fflush(stdio_stream); PerlIO_releaseFILE(stream, stdio_stream); PerlIO_printf(stream, "%s", SvPV_nolen(suffix)); PerlIO_flush(stream); } EOC for(1 .. 2) { foo(*stdout, "\nhello from perl\n"); } for(1 .. 2) { foo(*stderr); print "\nhello from perl\n"; } sub foo { if(@_ == 1) { _foo($_[0]) } elsif(@_ == 2) { _foo2($_[0], $_[1]) } else {die "Wrong no. of args to foo" } }
Cheers,
Rob

In reply to Re^6: Really, really suffering from buffering by syphilis
in thread Really, really suffering from buffering by syphilis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.