On Thu, Jun 23, 2011 at 6:06 AM, Kagamin <[email protected]> wrote:
> Jimmy Cao Wrote:
>
> > I don't think console output is unbuffered. I think it's line-buffered
> by
> > default. Although it does differ and vary; I think on Windows
> > std.stdio.write("hello\n") doesn't flush but on Linux it does.
>
> LOL, MS resource compiler doesn't use symantec C runtime.
> In fact sc runtime didn't flush, but this was fixed, though I don't
> remember where, in phobos or in sc.
>
I've tested it out with DMD 2.053 on Windows XP.
import std.stdio;
import core.thread;
void main()
{
version(WIDE) // Will flush during write
wstring mystr = "Hello\n"w;
else // Will not flush
string mystr = "Hello\n";
write(mystr);
Thread.sleep( 70_000_000 ); // 7 sec
stdout.flush();
}
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.