我有一个函数,它接受一个 int 指针并通过 boost::python 公开它。如何从 python 调用这个函数?
在带有 boost::python 的 C++ 中:
void foo(int* i);
...
def("foo", foo);
在蟒蛇中:
import foo_ext
i = 12
foo_ext.foo(i)
结果是
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
foo(int)
did not match C++ signature:
foo(int* i)
那么如何传递指针呢?