2016-02-22 40 views
0

錯誤編譯結構,我有以下代碼EM ++編譯:與emscripten

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); 
} 

而且我得到以下編譯錯誤:

error: C++ requires a type specifier for all declarations function("createBbox", &createBbox);

不介意定義之間的冗餘Point6f和containerBbox,這些都是不相關的,我甚至沒有設法讓emscripten頁面的例子工作(請參閱:https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#value-types),所以我不知道可能是什麼問題。

回答

1

與需要命名空間的value_obj類似,您需要將emscripten::放在function的前面。否則,編譯器認爲你正在聲明一個名爲function的C++函數,而不給它返回類型。

+0

謝謝先生,就是這樣! :) –