【问题标题】:How do you include external libraries into Haxe?如何将外部库包含到 Haxe 中?
【发布时间】:2015-03-18 17:55:42
【问题描述】:

我正在尝试编写一个程序,我想在 Haxe 中使用一些外部 C++ 库。由于官方文档太旧(http://old.haxe.org/doc/cpp/ffi)而且我对 C++ 也不熟悉,所以我无法弄清楚。

那么你如何在 Haxe 中做到这一点?我想我需要通过haxelib 安装hxcpp,但我知道的就这么多了。

【问题讨论】:

    标签: c++ haxe


    【解决方案1】:

    首先,请查看C++ Magic by Hugh Sanderson。该演讲中提到的大部分编译器元数据都可以在 Haxe 手册的Built-in Compiler Metadata 页面上找到。

    然后他简要地谈到了元数据魔法。他为类和函数提供元数据。对于课程,您有以下内容:

    @:headerClassCode(...) which injects member variables and inline functions.
    @:headerCode(...) which includes external headers.
    @:headerNamespaceCode(...) which allows you to add to the global namespace.
    @:cppFileCode(...) which allows you to include external headers only in C++ files.
    @:cppNamespaceCode(...) which implements static variables.
    @:buildXml(...) which allows you to add to the build.xml file. 
    

    对于函数元数据,您将获得以下信息:

    @:functionCode(...)
    @:functionTailCode(...) 
    

    Hugh 指出这些在很大程度上是多余的,因为您应该使用 untyped __cpp_(...) 代替。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-01
      • 2011-01-21
      • 2019-11-09
      • 1970-01-01
      • 1970-01-01
      • 2014-07-17
      相关资源
      最近更新 更多