如何将外部库包含到Haxe中

How do you include external libraries into Haxe?

本文关键字:Haxe 包含 外部      更新时间:2023-10-16

我正在尝试编写一个程序,我想在Haxe中使用一些外部C++库。我真的搞不清楚,因为官方文件太旧了(http://old.haxe.org/doc/cpp/ffi)而且我对C++也不熟悉。

那么你在哈克塞是怎么做到的呢?我想我需要通过haxelib安装hxcpp,但这已经是我所知道的了。

首先,请查看Hugh Sanderson的C++Magic。演讲中提到的编译器元数据可以在Haxe手册的内置编译器元数据页面中找到。

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

@: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(...) 

休表示,这些基本上是多余的,因为你应该使用非打字__改为cpp_(…)。