Building 64-bit Windows application with console window

Adam D. Ruppe destructionator at gmail.com
Wed Sep 18 00:30:51 UTC 2019


On Wednesday, 18 September 2019 at 00:13:43 UTC, cc wrote:
> Sample program here: https://pastebin.com/wpLetNKP

You have a WinMain function there. The Microsoft linker sees that 
as an indication that you are writing a Windows gui application 
and thus suppresses the console window.

Inside your program, you can always call the AllocConsole() 
function to pop up a console and attach it: 
https://docs.microsoft.com/en-us/windows/console/allocconsole

So a potential fix for you to just stick

debug AllocConsole();

right inside your WinMain before doing anything else.


Or my preference is to just never write WinMain in D. Just write 
a normal D main and use -L/subsystem:windows when you don't want 
the console (note: on 64 bit using the subsystem with normal 
main(), you also need to pass `-L/entry:mainCRTStartup.` to dmd 
so it uses the right entry point), and allow the defaults if you 
do want it.



More information about the Digitalmars-d-learn mailing list