digitalmars.D.learn - write not buffered with custom configuration
- Brother Bill (40/40) Feb 28 I used Copilot to finally get VSCode to debug D apps on both
- H. S. Teoh (7/13) Feb 28 In general, stderr is unbuffered, whereas stdout is buffered.
- Andy Valencia (6/7) Mar 01 POSIX has some implied fflush'ing of stdout, mostly having to do
I used Copilot to finally get VSCode to debug D apps on both
Windows and Linux.
This version is for Windows.
I noticed that write("Foo"); is eager like writeln(), and doesn't
need stdout.flush() to display on the console.
Is this due to my config files?
What would need to change in the config files to still maintain
debugging, but with write("Foo"); being buffered?
As this is a non-trivial project, I've saved it in adrive.com.
Here is the link, no credentials needed:
https://www.adrive.com/public/6XH96j/c02_p5_b_writeln_and_write_verbose.zip
source/app.d
```
void main()
{
import std.stdio : write, writeln, stderr, stdout;
// Let's first print what we have available:
stderr.write("Hello,");
// ... let's assume more operations at this point ...
stderr.write("World!");
// ... and finally this completes the writing to the console
with a newline
stderr.writeln();
// This writes: "Greetings, " to the stdout cache.
write("Greetings, ");
// This flushes the stdout cache, so the console displays:
Greetings,
stdout.flush();
// This writes: "World!" to the stdout cache.
write("World!");
// This flushes the stdout cache, so the console displays:
Greetings, World!
writeln();
write("I'm hiding! ");
write("Why don't you see me on the console!");
writeln; // Violates D Style Guidelines as this is a Command,
which should always have parentheses
}
```
Feb 28
On Sat, Feb 28, 2026 at 11:04:39AM +0000, Brother Bill via Digitalmars-d-learn
wrote:
I used Copilot to finally get VSCode to debug D apps on both Windows
and Linux.
This version is for Windows.
I noticed that write("Foo"); is eager like writeln(), and doesn't need
stdout.flush() to display on the console.
In general, stderr is unbuffered, whereas stdout is buffered.
Of course, your specific situation may be dependent on OS defaults as
well.
T
--
Creativity is not an excuse for sloppiness.
Feb 28
On Saturday, 28 February 2026 at 16:43:27 UTC, H. S. Teoh wrote:In general, stderr is unbuffered, whereas stdout is buffered.POSIX has some implied fflush'ing of stdout, mostly having to do with cases where stdin is a terminal. Modern best practices have converged on flushing for yourself at the point where you want the output to be seen. Andy
Mar 01








Andy Valencia <dont spam.me>