digitalmars.D.learn - Application with WinMain does not start
- Minas Mina (26/26) Mar 05 2016 I added a WinMain function to my application because I don't want
- Mike Parker (10/36) Mar 05 2016 When using WinMain, you are bypassing the DRuntime entry point,
- Mike Parker (5/6) Mar 05 2016 Actually, I need to amend that. It isn't needed with WinMain when
- Minas Mina (2/8) Mar 05 2016 Thanks. I removed the WinMain and it worked.
I added a WinMain function to my application because I don't want it to open a console when running on windows. But now it doesn't even start... extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { bool b = true; while (b) { sync(Clock.currTime(utcTimeZone())); Thread.sleep(getNextTimeToRun() - Clock.currTime(utcTimeZone())); } return 0; } And this is my DUB configuration: name "..." description "..." copyright "..." authors "..." targetType "executable" lflags "/SUBSYSTEM:windows" "/EXETYPE:NT" platform="windows" I got those flags from here: http://wiki.dlang.org/D_for_Win32 Any ideas:
Mar 05 2016
On Saturday, 5 March 2016 at 13:16:19 UTC, Minas Mina wrote:I added a WinMain function to my application because I don't want it to open a console when running on windows. But now it doesn't even start... extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { bool b = true; while (b) { sync(Clock.currTime(utcTimeZone())); Thread.sleep(getNextTimeToRun() - Clock.currTime(utcTimeZone())); } return 0; } And this is my DUB configuration: name "..." description "..." copyright "..." authors "..." targetType "executable" lflags "/SUBSYSTEM:windows" "/EXETYPE:NT" platform="windows" I got those flags from here: http://wiki.dlang.org/D_for_Win32 Any ideas:When using WinMain, you are bypassing the DRuntime entry point, meaning the runtime is never initialized. You need to do it manually. However, since you're passing /SUBSYSTEM:windows on the command line, you *don't need* WinMain. That flag is for when you want to use main, but don't want the console to popup. If you use WinMain, you do not need that flag. To keep things simple, I recommend you use the /SUBSYSTEM:windows flag together with a regular main and drop WinMain completely. You can drop the /EXETYPE flag as well.
Mar 05 2016
On Saturday, 5 March 2016 at 14:01:11 UTC, Mike Parker wrote:If you use WinMain, you do not need that flag.Actually, I need to amend that. It isn't needed with WinMain when using the Microsoft linker, but it is when using OPTLINK. The MS linker recognizes WinMain and treats it as /SUBSYSTEM:WINDOWS by default.
Mar 05 2016
On Saturday, 5 March 2016 at 14:08:28 UTC, Mike Parker wrote:On Saturday, 5 March 2016 at 14:01:11 UTC, Mike Parker wrote:Thanks. I removed the WinMain and it worked.If you use WinMain, you do not need that flag.Actually, I need to amend that. It isn't needed with WinMain when using the Microsoft linker, but it is when using OPTLINK. The MS linker recognizes WinMain and treats it as /SUBSYSTEM:WINDOWS by default.
Mar 05 2016