On Monday, 19 April 2021 at 16:04:28 UTC, Mike Parker wrote:
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote:
And upon running, the output I receive is:
```
[Main] Start
[Main] x: 5
[Main] Finished
[Main] END
[dll] DLL_PROCESS_ATTACH
[dll] static this for mydll
[dll] MyDLL_Test
[dll] DLL_PROCESS_DETACH
[dll] static ~this for mydll
```
I would expect the first three lines of dll output to precede
the "[Main] x:" line at least. Is there something I'm doing
wrong? Do I need to somehow pass a reference to the main
stdio to the DLL's D runtime similar to how the GC can be
shared?
It's probably just due to buffering. Insert a fflush(stdout)
after the calls to printf in your DLL and see what happens.
This seems to work if I flush after every printf or write in both
main and the dll. I was under the impression they were supposed
to share the same IO buffers though, is this not the case?