I have included the source to a simple 64-bit Windows program.
It compiles and runs fine with ```dmd -m64 -L="/Subsystem:Windows" -L="/Entry:Main" Main.d```. But compiling with ```-betterC``` using the following throws up a linker error, ```dmd -m64 -betterC -L="/Subsystem:Windows" -L="/Entry:Main" Main.d```:

```Main.obj : error LNK2019: unresolved external symbol _D4core3sys7windows7winuser11WNDCLASSEXA6__initZ referenced in function Main```

And I'm not sure why.

```d
import core.sys.windows.winuser;
import core.sys.windows.winbase;

pragma(lib, "User32.lib");
pragma(lib, "Kernel32.lib");

extern(Windows)
void Main(void* Instance)
{
    WNDCLASSEXA WindowClass;
    with (WindowClass)
    {
        cbSize        = WindowClass.sizeof;
        lpfnWndProc   = &WindowProc;
        hInstance     = Instance;
        hCursor       = LoadCursor(null, IDC_ARROW);
        lpszClassName = "Window";
    }
    RegisterClassExA(&WindowClass);
    void *WindowHandle = CreateWindowExA(0,
                                         "Window",
                                         "Window",
                                         WS_OVERLAPPEDWINDOW,
                                         CW_USEDEFAULT,
                                         CW_USEDEFAULT,
                                         CW_USEDEFAULT,
                                         CW_USEDEFAULT,
                                         null,
                                         null,
                                         Instance,
                                         null);
    ShowWindow(WindowHandle, SW_MAXIMIZE);

    MSG Message;
    while (GetMessage(&Message, null, 0, 0))
    {
        TranslateMessage(&Message);
        DispatchMessage(&Message);
    }
}

extern(Windows)
long WindowProc(void* WindowHandle, uint Message, ulong WParam, long LParam) nothrow @system
{
    if (Message == WM_DESTROY) ExitProcess(0);

    return DefWindowProcA(WindowHandle, Message, WParam, LParam);
}
```

Reply via email to