[C++-sig] Returning a simple char *
Simon Pickles
sipickles at googlemail.com
Tue Jan 12 09:16:54 CET 2010
Hello,
I thought I was trying to do something simple.
While wrapping a 3rd party library, I have a c++ class with two member
function returning pointers like this:
class videoInput
{
public:
static char * getDeviceName(int deviceID);
....
};
and a module like this:
#include "boost//python.hpp"
#include "videoInput.h"
using namespace boost::python;
BOOST_PYTHON_MODULE(pyVideoInput)
{
class_<videoInput>("videoInput")
.def("getDeviceName",
&videoInput::getDeviceName,
return_value_policy<manage_new_object>())
.staticmethod("getDeviceName")
;
}
Following the guide here
(http://wiki.python.org/moin/boost.python/PointersAndSmartPointers) I
thought this was the right way but I get errors:
pyVideoInput.cpp
C:\boost_1_41_0\boost/python/object/make_instance.hpp(24) : error C2027:
use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>
'
with
[
x=false
]
C:\boost_1_41_0\boost/python/to_python_indirect.hpp(95) : see
reference to function template instantiation 'PyObject *boos
t::python::objects::make_instance_impl<T,Holder,Derived>::execute<smart_pointer>(Arg
&)' being compiled
with
[
T=char,
Holder=holder_t,
Derived=boost::python::objects::make_ptr_instance<char,holder_t>,
Arg=smart_pointer
]
..................
pyVideoInput.cpp(16) : see reference to function template
instantiation 'boost::python::class_<W> &boost::python::class_<W
>::def<char*(__cdecl
*)(int),boost::python::return_value_policy<ResultConverterGenerator>>(const
char *,A1,const A2 &)' being comp
iled
with
[
W=videoInput,
ResultConverterGenerator=boost::python::manage_new_object,
A1=char *(__cdecl *)(int),
A2=boost::python::return_value_policy<boost::python::manage_new_object>
]
//////////////////////////
It seems to be attempting to use a smart_ptr?
Can anyone help explain this to me? Many thanks
Simon
More information about the Cplusplus-sig
mailing list