Building Win32 application via dub

Sam E. sam.e at example.org
Wed Apr 29 10:33:06 UTC 2020


On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote:
>> 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.

Just to confirm what Mike was saying: removing the WinMain 
completely and using a normal main function with calls to Win32 
functions builds and works perfectly fine, that's a way nicer 
approach.


More information about the Digitalmars-d-learn mailing list