zoukankan      html  css  js  c++  java
  • D语言 在ms-coff文件格式下使用DGUI库

            如果你使用DGUI库,同时又需要使用ms-coff格式的lib文件,那么你需要注意一些事情。

           在Visual-D中使用MS-COFF库文件格式需要选中以下两个选项:

    image      使用以下代码,编译时会出错

    import std.stdio;
    import dgui.all;
    import core.sys.windows.windows;
    import core.runtime;
    
    int main(string[] args)
    {
        Form f = new Form();
        f.size = Size(300,300);
        Application.run(f);
    }

    image

         错误提示找不到WinMain函数,这是因为使用微软的连接器,如果子系统为Windows时,会选择连接WinMain函数作为入口函数。

         处理这个问题有两个办法:

    一、把子系统改为 Console子系统

          image     这时候运行出来的程序会有一个命令行。  这个办法并不是很好。

    二、使用WinMain函数

    import std.stdio;
    import dgui.all;
    import core.sys.windows.windows;
    import core.runtime;
    
    extern (Windows)
        int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        Form f = new Form();
        f.size = Size(300,300);
        Application.run(f);
        return 0;
    }

         使用以上代码编译,会通过,再运行出来没有窗口出来。这是为什么呢??

         这是因为D语言运行时库没有初始化。需要修改代码如下:

    import std.stdio;
    import dgui.all;
    import core.sys.windows.windows;
    import core.runtime;
    
    extern (Windows)
        int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    {
        Runtime.initialize();
        scope(exit)Runtime.terminate();
    
        Form f = new Form();
        f.size = Size(300,300);
        Application.run(f);
        return 0;
    }

          OK,搞定,运行出来了

  • 相关阅读:
    自定义 radio 的样式,更改选中样式
    【Vue中的坑】vue项目中动态绑定src不显示图片解决方法
    js复制内容到剪切板
    js实现鼠标单击或者双击事件
    代码修改shader Properties uniform变量
    关于unity中BindChannels的理解
    shader Category
    Unity手游之路自动寻路Navmesh之高级主题
    Unity手游之路自动寻路Navmesh之入门
    Unity 自动寻路Navmesh之跳跃,攀爬,斜坡
  • 原文地址:https://www.cnblogs.com/wanhongnan/p/5774943.html
Copyright © 2011-2022 走看看