On Thu, Jun 23, 2011 at 6:06 AM, Kagamin <span dir="ltr"><spam@here.lot></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div>Jimmy Cao Wrote:<br>
<br>
> I don't think console output is unbuffered.  I think it's line-buffered by<br>
> default.  Although it does differ and vary; I think on Windows<br>
> std.stdio.write("hello\n") doesn't flush but on Linux it does.<br>
<br>
</div>LOL, MS resource compiler doesn't use symantec C runtime.<br>
In fact sc runtime didn't flush, but this was fixed, though I don't remember where, in phobos or in sc.<br>
</blockquote></div><br><div>I've tested it out with DMD 2.053 on Windows XP.</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>import std.stdio;</div>
</div><div><div>import core.thread;</div></div><div><div><br></div></div><div><div><br></div></div><div><div>void main()</div></div><div><div>{</div></div><div><div>    version(WIDE)  // Will flush during write</div></div>

<div><div>        wstring mystr = "Hello\n"w;</div>

</div><div><div>    else // Will not flush</div></div><div><div>        string mystr = "Hello\n";</div></div><div><div><br></div></div><div><div>    write(mystr);</div></div><div><div>    </div></div><div><div>


    Thread.sleep( 70_000_000 );  // 7 sec</div><div>    stdout.flush();</div>
</div><div><div>}</div></div><div><br></div></blockquote><div><div><br>Also, there's nothing in the C standard that says, stdout must be buffered this way or that way or even buffered at all.  I believe you can safely assume that stdout is line-buffered in Linux, though, but I'm not sure.
</div></div>