【发布时间】:2010-10-07 12:09:53
【问题描述】:
我有一个函数,它接受一个 int 指针并通过 boost::python 公开它。如何从 python 调用这个函数?
在 C++ 中使用 boost::python:
void foo(int* i);
...
def("foo", foo);
在python中:
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)
那么如何传递指针呢?
【问题讨论】:
标签: python pointers boost-python