D語言GUI編程-messagebox

爲了能理解D語言,試着從最簡單的GUI程序開始。
C++代碼如下
#include <windows.h>
#include <windowsx.h>

int WINAPI WinMain(HINSTANCE hinstance,
        HINSTANCE hprevinstance,
        LPSTR lpcmdline,
        int ncmdshow)
{
    MessageBox(NULL, "title","first win32",MB_OK | MB_ICONEXCLAMATION);
    return(0);
}

從DMD的sample中找到的例子,精簡後
gui1.d
---------------------------------------
import std.c.windows.windows;
import std.c.stdio;

int main()
{
    MessageBoxA(null, "aabc", "Error",MB_OK | MB_ICONEXCLAMATION);
    return 0;
}

build gui1.d -gui

但是
gui2.d
-----------------------------------
import std.c.windows.windows;
import std.c.stdio;

extern(Windows)
int WinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow)
{
/*
    try
    {
        int a = 0;
    }catch (Object o)        // catch any uncaught exceptions
    {
        int b = 0;
    }
*/
    MessageBoxA(null, "aabc", "Error",MB_OK | MB_ICONEXCLAMATION);
    return 0;
}
卻通不過,報錯爲
 Error 42: Symbol Undefined __acrtused
OPTLINK : Warning 134: No Start Address


如果將註釋去掉可以通過,也就是說加入那段即使沒有意義的異常處理卻可以通過?

大家有什麼解釋?
發佈了9 篇原創文章 · 獲贊 0 · 訪問量 1104
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章