On Thursday, 7 June 2018 at 19:19:55 UTC, realhet wrote:
Hi,

The following narrow test program works fine when compiled with DMD to 32bit target:

import std.stdio, core.sys.windows.windows, core.runtime;
extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
        Runtime.initialize;
        writeln("Hello");
        stdout.flush; //exception
        readln; //exception
        return 0;
}

It shows the console window and waits for user input at readln.

If I try to compile this to 64bit target or with LDC (both 32 and 64) it gets privileged instruction exception at stdout.flush. If I comment out flush then it fails at readln.

Is there a way to fix this? I don't wanna lose the console window even on 64bit.

Thanks!

You might be running into this issue: https://issues.dlang.org/show_bug.cgi?id=6880

I recall similar issues with a project I was working on, but I don't remember all the details now. Anyway, I ended up with this in the end.

https://github.com/JinShil/Dsus2/blob/b08c66c6a6efb46134c409aac9f1c600d62f99fa/Dsus2/main.d#L300-L331

Mike

Reply via email to