假设我有两个boost
python模块,定义如下.模块A:
class SomeClass { public: SomeClass() {} ~SomeClass() {} }; BOOST_PYTHON_MODULE(A) { class_<SomeClass>("SomeClass"); }
和模块B:
class AnotherClass { public: AnotherClass() {} ~AnotherClass() {} void func(SomeClass& sp) {} }; BOOST_PYTHON_MODULE(B) { class_<AnotherClass>("AnotherClass") .def("func",&AnotherClass::func) ; }
模块B依赖于模块A(即它使用模块A中的SomeClass).现在,我执行以下python脚本:
import A import B obj1 = A.SomeClass() obj2 = B.AnotherClass() obj2.func(obj1)
我收到以下错误:
Traceback (most recent call last): File "C:\bladiebla\script.py",line 8,in <module> obj2.func(obj1) ArgumentError: Python argument types in AnotherClass.func(AnotherClass,SomeClass) did not match C++ signature: func(class AnotherClass {lvalue},class SomeClass)