我尝试使用SWIG扩展Matrix类以创建python接口。我使用了官方的Docu码。但是我得到了一个完全荒谬的错误消息。在声明我的行类的地方似乎并不重要。我总是在编译时收到此错误。SWIG有什么问题?错误: ANPyNetCPUPYTHON_wrap.cxx: In function ‘ANN::F2DArray ANN_F2DArray___getitem__(ANN::F2DArray*, int)’: ANPyNetCPUPYTHON_wrap.cxx:5192: error: ‘Grid2dRow’ was not declared in this scope ANPyNetCPUPYTHON_wrap.cxx:5192: error: expected `;' before ‘r’ ANPyNetCPUPYTHON_wrap.cxx:5193: error: ‘r’ was not declared in this scope代码: %{ #include <AN2DArray.h> %} %include <AN2DArray.h> %inline %{ struct Grid2dRow { ANN::F2DArray *g; // Grid int y; // Row number // These functions are used by Python to access sequence types (lists, tuples, ...) float __getitem__(int x) { return g->GetValue(x, y); } void __setitem__(int x, float val) { g->SetValue(x, y, val); } }; %} %extend ANN::F2DArray { ANN::F2DArray __getitem__(int y) { Grid2dRow r; r.g = self; r.y = y; return r; } };
添加回答
举报
0/150
提交
取消