On Monday, 26 April 2021 at 13:44:19 UTC, frame wrote:
On Sunday, 25 April 2021 at 15:01:25 UTC, cc wrote:

Adding a note in case anyone stumbles across this with a similar problem: Adding `stdout.setvbuf(0, _IONBF);` to both the main and DLL will cause D to autoflush after every write call without requiring a manual flush (which seems to happen quite often when running under anything other than a basic Windows command prompt).

I cannot reproduce this on Windows 10. It would be just interesting to know your compiler version and OS and if you have installed any Visual Studio tools or Visual C runtimes, thanks.

Win10 64-bit
DMD32 D Compiler v2.096.0-dirty
Sublime Text 3.1.1 Build 3176
Visual Studio 2019 is installed, as well as... quite a few runtimes, multiple for Visual C++ 2005, 2008, 2010, 2012, 2013, 2015-2019.

The buffering also happens under cygwin shells (I'm not building with cygwin, I just like using their bash shell). If I run a D program through the basic cmd.exe, it runs with no stdout buffering. However any other situation (shell, sublime build+output capture, etc) buffering somehow gets enabled, unless I explicitly disable it in code or wrap the write* functions with stdout.flush() wrappers. This has happened for me for many versions of the dmd compiler stretching back years, building both 32-bit and 64-bit executables.

Reply via email to