Calling main() from WinMain()
BLM768
blm768 at gmail.com
Tue Jun 5 07:40:26 PDT 2012
I'm working on a cross-platform GUI library and I'd like to be
able to call the user's main() function from WinMain() so users
don't have to write both functions. However, I'm at a bit of a
loss as to how to accomplish that. I know that D internally
creates the extern(C) main(), which in turn calls D's main(), but
I think that the C main() also performs some runtime
initialization, which means that I probably shouldn't be calling
it after WinMain() has already started. Since the D main() is
defined at module scope, I'm not sure how to access it without
importing one of the user's modules. I think that each module can
define its own main() as well, which really complicates things.
Is there a reasonably simple way to get the right main() function?
I hate to say it, but this is a problem that would actually be
easier in C++ :)
More information about the Digitalmars-d-learn
mailing list