Building Win32 application via dub

Sam E. sam.e at example.org
Wed Apr 29 10:26:40 UTC 2020


On Wednesday, 29 April 2020 at 10:12:29 UTC, Mike Parker wrote:
> Most likely because you're calling writeln before initializing 
> the runtime.

Of course, that was it, thanks for the help Mike!

> Also, when using WinMain, you aren't going to see any output 
> from writeln because you won't have a console window. The 
> linker will create a "Windows subsystem" app rather than a 
> "Console subsystem".

Thanks again, you're right, I didn't realize that would be the 
case.

> Really, there's no reason at all to use WinMain. Just create a 
> standard main function. Then you don't need to worry about 
> manually initializing the runtime and you'll have a console 
> window by default. You can always turn it off in anything you 
> want to ship without the console by adding the appropriate 
> dflags to your dub file:
>
> -L/SUBSYSTEM:WINDOWS -L/ENTRY:mainCRTStartup
>
> Conversely, you can get the console window in a WinMain app 
> with:
>
> -L/SUBSYSTEM:CONSOLE -L/ENTRY:WinMainCRTStartup
>
> Though, again, there's really no reason to use WinMain.

I took the WinMain from https://wiki.dlang.org/D_for_Win32, 
should that documentation be updated to use a normal main 
function instead? Also the details regarding linker flags may be 
a good addition to that wiki page.


More information about the Digitalmars-d-learn mailing list