calling D2 routines from C routines on linux
Jimmy Cao
jcao219 at gmail.com
Tue Jul 19 22:06:30 PDT 2011
Oh, I see.
That's very convenient.
On Wed, Jul 20, 2011 at 12:04 AM, Andrej Mitrovic <
andrej.mitrovich at gmail.com> wrote:
> On 7/20/11, Jimmy Cao <jcao219 at gmail.com> wrote:
> > What? I've never needed to do that when compiling programs with
> > -L/exet:nt/su:windows:4.0
> > on Windows.
> >
>
> If you use a main() function, DMD will add the runtime stuff for you.
> 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
> ---------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20110720/23926830/attachment.html>
More information about the Digitalmars-d-learn
mailing list