Why is the Win32 boilerplate the way it is?
Jeremy Sorensen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 28 21:47:31 PDT 2014
I found an example of boilerplate code for Win32 programming in D
here:
http://wiki.dlang.org/D_for_Win32
I have some questions.
1. It appears that the call to myWinMain from WinMain is to
ensure that any exception or error is caught. At first glance it
looks like this is to ensure that runtime.terminate() gets
called, but in fact it doesn't, the catch block doesn't do it and
there is no scope(exit). Is this a problem? (And what would
happen if you didn't catch the exception?)
2. Why does the boilerplate return 0 on success and failure? (If
the return code is irrelevant, why the comment that says "failed"
next to the return code?)
3. I can't imagine a technical reason why the myWinMain signature
has to match the WinMain signature. Wouldn't it be better to omit
the hPrevInstance since it isn't used? (Or are we preserving
backwards compatibility with Win16?).
If there is a resource somewhere that explains all this I would
happy to consult it but I couldn't find anything.
Thanks.
More information about the Digitalmars-d-learn
mailing list