【问题标题】:How can I use simple c++ code in Haxe Project?如何在 Haxe Project 中使用简单的 c++ 代码?
【发布时间】:2015-12-16 22:40:14
【问题描述】:

我在 cpp 中有一个类,例如:

class Foo{
private:
    int x;
public:
    Foo(){x = 0;}
    int incr();
};

int Foo::incr(){
    x++;
    return x;
}

在任何 .hx 文件中,我想使用像这样在 cpp 中定义的 Foo 类:

var number:Int;
// Some codes to create foo_1 object "Foo foo_1;"

// Some codes to call "number = foo_1.incr();"
trace("x is:" + number);
// Some codes to call "number = foo_1.incr();"
trace("x is:" + number);

预期输出是

x is:1
x is:2

作为说明,我搜索并阅读了一些关于 hxcppHaxe CFFI 的文档,但这些文档的某些部分过于复杂。我是 Haxe 的初学者,我需要基本和简单的步骤来解决这个问题。谢谢。

【问题讨论】:

    标签: c++ haxe cffi hxcpp


    【解决方案1】:

    我曾尝试将其用于一个研究项目,但这远非简单。文档非常稀缺,缺乏逆向工程 hxcpp,几乎没有其他内容可做。

    也就是说,据我所知,extern 类是直接从 Haxe 访问 C++ 对象的唯一方法。不过,并非没有脚手架。

    你可以阅读一个人的经历here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多