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
如果將註釋去掉可以通過,也就是說加入那段即使沒有意義的異常處理卻可以通過?
大家有什麼解釋?