Hi,

I'm having compilation errors as soon as I give my classes member variables 
that come from the boost thread library.
Wrapping those in shared_ptr seems to work.

Any idea why? Is there a special wrapping directive I should give it to?


#include <vector>
#include <boost/python.hpp>
#include <boost/thread.hpp>


struct Hello {
Hello(){}

bool run(int argc, char **argv, char **envp);
std::string hello_string_;
std::vector<std::string> hello_vector_ ;
size_t hello_num_;
boost::shared_ptr<std::string> hello_shared_ptr_string_;
bool hello_bool_;
boost::shared_ptr<boost::condition_variable> condition_variable_shared_ptr_;

// does not compile
//boost::condition_variable condition_variable_;
};


char const* greet()
{
return "hello, world";
}


BOOST_PYTHON_MODULE(hello)
{
using namespace boost::python;
def("greet", greet);
class_<Hello>("Hello");
}




$ make
g++ -c -o hello.o 
-I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/ 
-Wall -O3 -fPIC -g hello.cpp
/usr/local/include/boost/python/object/value_holder.hpp: In constructor 
‘boost::python::objects::value_holder<Value>::value_holder(PyObject*, A0) [with 
A0 = boost::reference_wrapper<const Hello>, Value = Hello]’:
/usr/local/include/boost/python/object/make_instance.hpp:71:  instantiated from 
‘static Holder* boost::python::objects::make_instance<T, 
Holder>::construct(void*, PyObject*, boost::reference_wrapper<const T>) [with T 
= Hello, Holder = boost::python::objects::value_holder<Hello>]’
/usr/local/include/boost/python/object/make_instance.hpp:45:  instantiated from 
‘static PyObject* boost::python::objects::make_instance_impl<T, Holder, 
Derived>::execute(Arg&) [with Arg = const boost::reference_wrapper<const 
Hello>, T = Hello, Holder = boost::python::objects::value_holder<Hello>, 
Derived = boost::python::objects::make_instance<Hello, 
boost::python::objects::value_holder<Hello> >]’
/usr/local/include/boost/python/object/class_wrapper.hpp:29:  instantiated from 
‘static PyObject* boost::python::objects::class_cref_wrapper<Src, 
MakeInstance>::convert(const Src&) [with Src = Hello, MakeInstance = 
boost::python::objects::make_instance<Hello, 
boost::python::objects::value_holder<Hello> >]’
/usr/local/include/boost/python/converter/as_to_python_function.hpp:27:  
instantiated from ‘static PyObject* 
boost::python::converter::as_to_python_function<T, ToPython>::convert(const 
void*) [with T = Hello, ToPython = 
boost::python::objects::class_cref_wrapper<Hello, 
boost::python::objects::make_instance<Hello, 
boost::python::objects::value_holder<Hello> > >]’
/usr/local/include/boost/python/to_python_converter.hpp:87:  instantiated from 
‘boost::python::to_python_converter<T, Conversion, 
has_get_pytype>::to_python_converter() [with T = Hello, Conversion = 
boost::python::objects::class_cref_wrapper<Hello, 
boost::python::objects::make_instance<Hello, 
boost::python::objects::value_holder<Hello> > >, bool has_get_pytype = true]’
/usr/local/include/boost/python/object/class_wrapper.hpp:26:  instantiated from 
‘static void boost::python::objects::class_metadata<T, X1, X2, 
X3>::maybe_register_class_to_python(T2*, mpl_::false_) [with T2 = Hello, T = 
Hello, X1 = boost::python::detail::not_specified, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/usr/local/include/boost/python/object/class_metadata.hpp:229:  instantiated 
from ‘static void boost::python::objects::class_metadata<T, X1, X2, 
X3>::register_aux2(T2*, Callback) [with T2 = Hello, Callback = 
boost::integral_constant<bool, false>, T = Hello, X1 = 
boost::python::detail::not_specified, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/usr/local/include/boost/python/object/class_metadata.hpp:219:  instantiated 
from ‘static void boost::python::objects::class_metadata<T, X1, X2, 
X3>::register_aux(void*) [with T = Hello, X1 = 
boost::python::detail::not_specified, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/usr/local/include/boost/python/object/class_metadata.hpp:205:  instantiated 
from ‘static void boost::python::objects::class_metadata<T, X1, X2, 
X3>::register_() [with T = Hello, X1 = boost::python::detail::not_specified, X2 
= boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/usr/local/include/boost/python/class.hpp:496:  instantiated from ‘void 
boost::python::class_<T, X1, X2, X3>::initialize(const DefVisitor&) [with 
DefVisitor = boost::python::init<mpl_::void_, mpl_::void_, mpl_::void_, 
mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, 
mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_>, 
W = Hello, X1 = boost::python::detail::not_specified, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
/usr/local/include/boost/python/class.hpp:629:  instantiated from 
‘boost::python::class_<T, X1, X2, X3>::class_(const char*, const char*) [with W 
= Hello, X1 = boost::python::detail::not_specified, X2 = 
boost::python::detail::not_specified, X3 = 
boost::python::detail::not_specified]’
hello.cpp:32:  instantiated from here
/usr/local/include/boost/python/object/value_holder.hpp:137: error: no matching 
function for call to ‘Hello::Hello(const Hello&)’
hello.cpp:7: note: candidates are: Hello::Hello()
hello.cpp:6: note:  Hello::Hello(Hello&)
make: *** [hello.o] Error 1


_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to