On Saturday, 5 September 2015 at 01:49:22 UTC, Adam D. Ruppe wrote:
On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote:
extern (Windows) int WinMain(...)

If you use WinMain in D, you'll also have to initialize the D runtime yourself, which will call static constructors and such.

You'd be better off just using a regular main() function, then passing the `-L/SUBSYSTEM:WINDOWS:5.0` option to dmd when building (at least on 32 bit, not sure if it is the same on 64 bit or not) so the linker makes a gui app - same as it does when it detects a WinMain in the program.


const MyApp = Application.New({ std.stdio.writeln("MY APP IS COOL"); });

Remember, gui apps don't necessarily have a console, so writeln may fail!

Maybe, but the error relates to be being called statically.


(The main reason for doing this is to make it easier for writing portable apps)


Just using a regular main function is the most portable solution. Then just offer helper functions or something to help with the boilerplate.

Essentially that is what I'm doing. I have divided the app into different types using versioning. The application class is a generic wrapper for the main possibilities(win32, Win64, mac, linux, etc).

Basically WinMain is used when version is Win32 or Win64 so it is not a problem with the stuff you have mentioned. At some point I will make it all work but I need to get off the ground first. I can always force the user to jump through some hoops but I'd like to avoid that as much as possible since I'm the user and I don't like hoops.




Reply via email to