Oh, I see.
On 7/20/11, Jimmy Cao <jcao219@gmail.com> wrote:If you use a main() function, DMD will add the runtime stuff for you.
> What? I've never needed to do that when compiling programs with
> -L/exet:nt/su:windows:4.0
> on Windows.
>
But if you use WinMain as your main function, you have to initialize
manually.
For example, if you try to compile and run this app:
module win;
import core.runtime;
import std.c.windows.windows;
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int iCmdShow)
{
int[] a;
a.length = 5000;
auto b = a[];
return 1;
}
> dmd win.d -L/exet:nt/su:windows:4.0 && win.exe
You'll see that it crashes:
---------------------------
win.exe - Application Error
---------------------------
The instruction at "0x00407cf6" referenced memory at "0x00000000". The
memory could not be "read".
Click on OK to terminate the program
Click on CANCEL to debug the program
---------------------------
OK Cancel
---------------------------