www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - write not buffered with custom configuration

reply Brother Bill <brotherbill mail.com> writes:
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
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
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
parent Andy Valencia <dont spam.me> writes:
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