Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread Mike Parker via Digitalmars-d-learn
On Monday, 26 April 2021 at 14:44:53 UTC, cc wrote: 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,

Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread frame via Digitalmars-d-learn
On Monday, 26 April 2021 at 14:44:53 UTC, cc wrote: Visual Studio 2019 is installed, as well as... quite a few runtimes, multiple for Visual C++ 2005, 2008, 2010, 2012, 2013, 2015-2019. like me If I run a D program through the basic cmd.exe, it runs with no stdout buffering. Does it

Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 April 2021 at 14:44:53 UTC, cc wrote: I run a D program through the basic cmd.exe, it runs with no stdout buffering. You'll find the same thing with C programs, since it is actually the C standard library that does this buffering rather than D. If it is writing to a character

Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread cc via Digitalmars-d-learn
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

Re: win64 DLL stdout printing after main process completes

2021-04-26 Thread frame via Digitalmars-d-learn
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

Re: win64 DLL stdout printing after main process completes

2021-04-25 Thread cc via Digitalmars-d-learn
On Monday, 19 April 2021 at 18:32:15 UTC, Adam D. Ruppe wrote: On Monday, 19 April 2021 at 18:05:46 UTC, cc wrote: 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

Re: win64 DLL stdout printing after main process completes

2021-04-20 Thread Marcone via Digitalmars-d-learn
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote: I'm not sure if this is something unique to D or not, but I've having a minor issue where stdout output from a DLL (either via printf or phobos std.stdio write) is not displayed until after the main process has completed. I'm making a

Re: win64 DLL stdout printing after main process completes

2021-04-20 Thread Mike Parker via Digitalmars-d-learn
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote: 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

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 April 2021 at 18:05:46 UTC, cc wrote: 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? Very little in D dlls right now are shared, so

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote: https://wiki.dlang.org/Win32_DLLs_in_D I'm starting to think half that page should just be deleted... the version up top with the druntime dll_process_attach etc versions should really be used in all cases. And that gets even simpler too,

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread cc via Digitalmars-d-learn
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]

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread cc via Digitalmars-d-learn
On Monday, 19 April 2021 at 16:00:25 UTC, frame wrote: You miss a core.stdc.stdio import in main(). I also omit the def-File, maybe you have an error in it? It shouldn't be necessary to include. It just did: ``` dmd -m64 -ofmydll.dll -L/DLL mydll.d ``` Sorry, here's the def file, taken from

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread Mike Parker via Digitalmars-d-learn
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

Re: win64 DLL stdout printing after main process completes

2021-04-19 Thread frame via Digitalmars-d-learn
On Monday, 19 April 2021 at 14:55:03 UTC, cc wrote: 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

win64 DLL stdout printing after main process completes

2021-04-19 Thread cc via Digitalmars-d-learn
I'm not sure if this is something unique to D or not, but I've having a minor issue where stdout output from a DLL (either via printf or phobos std.stdio write) is not displayed until after the main process has completed. I'm making a project based around the example at