使用emscripten编译结构时出错
Error compiling structures with emscripten
我用em++编译了以下代码:
struct Point6f{
float x0;
float y0;
float z0;
float x1;
float y1;
float z1;
};
struct containerBbox {
float x0;
float y0;
float z0;
float x1;
float y1;
float z1;
};
containerBbox createBbox(Point6f);
EMSCRIPTEN_BINDINGS(my_value_example) {
emscripten::value_array<Point6f>("Point6f")
.element(&Point6f::x0)
.element(&Point6f::y0)
.element(&Point6f::z0)
.element(&Point6f::x1)
.element(&Point6f::y1)
.element(&Point6f::z1);
emscripten::value_object<containerBbox>("containerBox")
.field("x0", &containerBbox::x0)
.field("y0", &containerBbox::y0)
.field("z0", &containerBbox::z0)
.field("x1", &containerBbox::x1)
.field("y1", &containerBbox::y1)
.field("z1", &containerBbox::z1)
;
function("createBbox", &createBbox);
}
我得到以下编译错误:
错误:C++要求所有声明都使用类型说明符函数("createBbox",&createBbox(;
不要介意Point6f和containerBbox的定义之间的冗余,这些都无关紧要,我甚至没能让emscripten页面的例子发挥作用(请参阅:https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#value-类型(,所以我不确定问题出在哪里。
类似于value_obj
需要名称空间,您需要将emscripten::
放在function
前面。否则,编译器会认为您在声明一个名为function
的C++函数,而没有给它返回类型。
相关文章:
- 为什么我在初始化带大括号的结构时出错?
- 尝试将指针与结构一起使用时出错
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- 尝试初始化结构内的联合时出错
- 当使用 std::CIN 输入结构时,它会出错
- 在 boost::heap::p riority_queue 中推送结构对象时出错
- 确定输入"conscalc: calc"的类型时出错。不能联合编码器。具有不同字段集的结构类型
- 尝试将数据添加到结构内部的矢量时出错
- 使用提升库在队列和堆栈数据结构上保存和加载数据时出错
- 尝试将结构指针传递给类时出错
- 在旧的 c++ (<c++11) 中,初始化结构会出错
- 类中私有结构的构造函数出错
- 读取结构数组时出错
- 将模板参数传递到内部结构时出错
- 创建局部结构的 std::向量时出错
- 在 C++ 中访问泛型结构的成员会出错
- 使用映射<字符串,结构>类型的映射编译头文件时出错
- 使用单元测试 (cppunit) 中另一个文件中定义的结构时出错
- 初始化作为结构成员的函数指针时出错
- 使用嵌套结构将结构作为引用传递时出错