[Issue 2580] New: Documented WinMain for D2 is wrong
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 11 12:22:20 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2580
Summary: Documented WinMain for D2 is wrong
Product: D
Version: 2.023
Platform: PC
URL: http://www.digitalmars.com/d/2.0/windows.html
OS/Version: Windows
Status: NEW
Keywords: spec
Severity: critical
Priority: P2
Component: www.digitalmars.com
AssignedTo: bugzilla at digitalmars.com
ReportedBy: smjg at iname.com
Currently, the form of WinMain documented for D2 is the same as that for D1.
However, it's no good. _moduleUnitTests() doesn't exist in D2 for a start; a
more subtle yet more serious problem is that it doesn't initialise the GC
properly.
After a day or three of driving myself mad trying to figure why one of my apps
was unstable under D2, I've finally come up with a form for WinMain that seems
to work:
----------
import std.c.windows.windows;
import core.runtime;
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
try {
Runtime.initialize();
runModuleUnitTests();
return myWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
} catch (Object o) {
MessageBoxA(null, toStringz(o.toString()),
"Fatal Internal Error", MB_OK | MB_ICONEXCLAMATION);
return 0;
} finally {
Runtime.terminate();
}
}
--
More information about the Digitalmars-d-bugs
mailing list