Programming Windows D Examples are now Online!
Jimmy Cao
jcao219 at gmail.com
Thu Jun 23 04:27:34 PDT 2011
On Thu, Jun 23, 2011 at 6:06 AM, Kagamin <spam at here.lot> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20110623/c2ead91b/attachment.html>
More information about the Digitalmars-d-announce
mailing list