`
smithfox
  • 浏览: 54024 次
  • 性别: Icon_minigender_1
  • 来自: hf
社区版块
存档分类
最新评论

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


如果将注释去掉可以通过,也就是说加入那段即使没有意义的异常处理却可以通过?

大家有什么解释?
分享到:
评论
1 楼 soulmachine 2007-04-22  
我有几个例子也有这样的问题,总是说Symbol Undefined __acrtused,官网上一直找不到简短点的GUI编程的例子。

相关推荐

Global site tag (gtag.js) - Google Analytics