Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have some C++ function (not mine, so i can't edit):

void MyClass::SetOnConnect(bool (*pfn)(void * pParam), void * pParam)
{
  pfnCallBack = pfn;
  pCallBackParam = pParam;
}

later in code it will be invoked by (*pfnCallBack)(pCallBackParam);

So when I just put my def in BOOST_PYTHON_MODULE:

    .def("SetOnConnect", &MyClass::SetOnConnect)

and getting compiling error:

! /boost_1_52_0/boost/python/converter/registered.hpp: In instantiation of ‘const boost::python::converter::registration& boost::python::converter::detail::registry_lookup2(T& ()()) [with T = bool(void)]’: /boost_1_52_0/boost/python/converter/registered.hpp:94:40: required from ‘const boost::python::converter::registration& boost::python::converter::detail::registry_lookup1(boost::type) [with T = bool (&)(void*)]’ /boost_1_52_0/boost/python/converter/registered.hpp:105:23: required from ‘const boost::python::converter::registration& boost::python::converter::detail::registered_base::converters’ /boost_1_52_0/boost/python/converter/arg_from_python.hpp:269:99: required from ‘boost::python::converter::pointer_arg_from_python::pointer_arg_from_python(PyObject*) [with T = bool ()(void); PyObject = _object]’ /boost_1_52_0/boost/python/arg_from_python.hpp:70:18: required from ‘boost::python::arg_from_python::arg_from_python(PyObject*) [with T = bool ()(void); PyObject = _object]’ /boost_1_52_0/boost/preprocessor/iteration/detail/local.hpp:37:1: required from ‘PyObject* boost::python::detail::caller_arity<3u>::impl::operator()(PyObject*, PyObject*) [with F = void (MyClass::)(bool ()(void*), void*); Policies = boost::python::default_call_policies; Sig = boost::mpl::vector4; PyObject = _object]’ /boost_1_52_0/boost/python/object/py_function.hpp:38:33: required from ‘PyObject* boost::python::objects::caller_py_function_impl::operator()(PyObject*, PyObject*) [with Caller = boost::python::detail::caller >; PyObject = _object]’ MOOSLIB/pyTest.cpp:195:1: required from here /boost_1_52_0/boost/python/converter/registered.hpp:86:7: error: no matching function for call to ‘register_shared_ptr1(bool ()(void))’ /boost_1_52_0/boost/python/converter/registered.hpp:86:7: note: candidate is: /boost_1_52_0/boost/python/converter/registered.hpp:77:3: note: template void boost::python::converter::detail::register_shared_ptr1(const volatile T*) /boost_1_52_0/boost/python/converter/registered.hpp:77:3: note: template argument deduction/substitution failed: /boost_1_52_0/boost/python/converter/registered.hpp:86:7: note: types ‘const volatile T’ and ‘bool(void*)’ have incompatible cv-qualifiers

Can anybody tell my how to write a thin wrapper for this? Thank you for any help.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.