[C++-sig] .def(str(self)) compile problems
Simon Burton
simon at arrowtheory.com
Sun Feb 20 22:08:17 CET 2005
Hi !
I'm having trouble getting the __str__ wrapper for my C++ class to compile.
Everything else i've tried works fine (methods/functions/operators), but when I include the .def( str(self) )
line the compilation fails. Any help much appreciated. I am new to python/C++, but have
done a lot of python/C interfacing.
details follow.
Simon.
blue:~/home/cpp/break$ bjam -sTOOLS=gcc lift
...found 1537 targets...
...updating 2 targets...
gcc-C++-action bin/break/lift.so/gcc/debug/shared-linkable-true/lift.o
/home/simon/local/boost_1_32_0/boost/python/def_visitor.hpp: In static member function `static void boost::python::def_visitor_access::visit(const V&, classT&) [with V = boost::python::def_visitor<boost::python::api::object>, classT = boost::python::class_<interval, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>]':
/home/simon/local/boost_1_32_0/boost/python/def_visitor.hpp:67: instantiated from `void boost::python::def_visitor<DerivedVisitor>::visit(classT&) const [with classT = boost::python::class_<interval, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, DerivedVisitor = boost::python::api::object]'
/home/simon/local/boost_1_32_0/boost/python/class.hpp:225: instantiated from `boost::python::class_<T, X1, X2, X3>& boost::python::class_<T, X1, X2, X3>::def(const boost::python::def_visitor<Derived>&) [with Derived = boost::python::api::object, W = interval, X1 = boost::python::detail::not_specified, X2 = boost::python::detail::not_specified, X3 = boost::python::detail::not_specified]'
lift.cpp:12: instantiated from here
/home/simon/local/boost_1_32_0/boost/python/def_visitor.hpp:31: error: no matching function for call to `boost::python::api::object::visit(boost::python::class_<interval, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>&) const'
set -e
"g++" -c -Wall -ftemplate-depth-255 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 -fno-inline -fPIC -I"bin/break" -I "/usr/local//include/python2.3" -I "/home/simon/local/boost_1_32_0" -o "bin/break/lift.so/gcc/debug/shared-linkable-true/lift.o" "lift.cpp"
"/usr/bin/objcopy" --set-section-flags .debug_str=contents,debug "bin/break/lift.so/gcc/debug/shared-linkable-true/lift.o"
...failed gcc-C++-action bin/break/lift.so/gcc/debug/shared-linkable-true/lift.o...
...removing bin/break/lift.so/gcc/debug/shared-linkable-true/lift.o
...skipped <@break/lift.so/gcc/debug/shared-linkable-true>lift.so for lack of <@break/lift.so/gcc/debug/shared-linkable-true>lift.o...
...failed updating 1 target...
...skipped 1 target...
blue:~/home/cpp/break$
blue:~/home/cpp/break$ g++ --version
g++ (GCC) 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)
blue:~/home/cpp/break$ cat interval.hpp
class interval
{
public:
class division : public std::exception {};
class disorder : public std::exception {};
interval() : _lower(), _upper() {}
private:
double _lower;
double _upper;
friend double lower(const interval&);
friend double upper(const interval&);
};
inline double lower(const interval& x) { return x._lower; }
inline double upper(const interval& x) { return x._upper; }
std::ostream& operator<<(std::ostream& x, interval y)
{
return x << '[' << lower(y) << ',' << upper(y) << ']';
}
blue:~/home/cpp/break$ cat lift.cpp
#include <boost/python.hpp>
#include "interval.hpp"
using namespace boost::python;
BOOST_PYTHON_MODULE(lift)
{
class_< interval >("interval", init< >())
.def( str(self) )
;
def( "lower", lower );
def( "upper", upper );
}
blue:~/home/cpp/break$ cat Jamfile
project-root ;
import python ;
extension lift
:
lift.cpp
<template>@boost/libs/python/build/extension
;
blue:~/home/cpp/break$ cat Jamrules
path-global BOOST_ROOT : /home/simon/local/boost_1_32_0 ;
project boost : $(BOOST_ROOT) ;
blue:~/home/cpp/break$
--
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com
More information about the Cplusplus-sig
mailing list