我为一个C++库创建Python绑定,我有头文件/LIB文件,但是这个函数以2D数组作为参数,没有被pyBDN11自动转换。如何正确地转换这个论点?在
头文件将此函数声明为
class __declspec(dllimport) SomeClass {
public:
void function(uint32_t arg1, uint32_t arg2, float matrix[3][3]);
我把它绑起来
^{pr2}$python setup.py bdist_wheel
输出以下内容(注释function
绑定可以很好地构建轮子)
C:\Users\joona\git\someproject\pybind11\include\pybind11\cast.h(1931,1): error C2664: 'Return pybind11::cpp_function::{ctor}::<lambda_b1f1895366c1273186f52810f5be9d13>::operator ()(Class *,uint32_t ,uint32_t ,float (*)[3]) const': cannot convert argument 4 from 'float *' to 'float (*)[3]' [C:\Users\joona\git\someproject\build\temp.win-amd64-3.7\Release\someproject.vcxproj]
我会选择
std::array
:pybind将知道如何将其转换为2d列表。 另外,在cpp代码中,访问权限与
float[3][3]
相同。在编辑:
根据您的评论,我认为您可以使用类似的方法(参见from pybind documentation):
^{pr2}$这里我假设矩阵只是函数的输入;如果结果也是输出的,可以将结果复制回std数组。在
相关问题 更多 >
编程相关推荐