console output in dll doesn't work

Rainer Schuetze r.sagitario at gmx.de
Wed Mar 31 11:36:33 PDT 2010


Trass3r wrote:
> I tried the simple(st) official dll example (which I fixed slightly to 
> compile; using the dll_helper module etc)
> 

What was the fix? The example in samples/d/mydll compiles fine and looks 
very much the same.

> export void dllprint() { write("hello dll world\n"); }
> 
> The code is executed (I checked with a debugger) but nothing is printed 
> in the console window.

In contrast to printf the std.stdio.write functions seem to buffer the 
output. When the DLL is unloaded, console output is already closed by 
the application.

Two possible solutions:
1. call stdout.flush() after writing
2. set std.c.stdio._fcloseallp = null; before terminating the exe, but 
expect scrumbled output from the DLL and the exe



More information about the Digitalmars-d mailing list