Hello, I have written a simple hello.cpp - [1], which doesn't compile - [2]. After some "investigation" I have tracked down the problem to boost/python/str.hpp header. Removing str.hpp and numeric.hpp, which includes it, from python.hpp make the hello.cpp compile and work just fine:
import hello blah = hello.World() blah.set("foo") print blah foo
System info: boost=1.33.1, gcc-4.1.2, glibc-2.5, kernel 2.6.20-gentoo x86_64, python-2.4.4 [1] = http://dev.gentooexperimental.org/~peper/boost/hello.cpp [2] - http://dev.gentooexperimental.org/~peper/boost/hello.error -- Best Regards, Piotr Jaroszynski
On 3/10/07, Piotr Jaroszynski <p.jaroszynski@gmail.com> wrote:
Hello,
I have written a simple hello.cpp - [1], which doesn't compile - [2]. After some "investigation" I have tracked down the problem to boost/python/str.hpp header. Removing str.hpp and numeric.hpp, which includes it, from python.hpp make the hello.cpp compile and work just fine:
import hello blah = hello.World() blah.set("foo") print blah foo
System info: boost=1.33.1, gcc-4.1.2, glibc-2.5, kernel 2.6.20-gentoo x86_64, python-2.4.4
[1] = http://dev.gentooexperimental.org/~peper/boost/hello.cpp [2] - http://dev.gentooexperimental.org/~peper/boost/hello.error
This is a known problem/bug. The work around is pretty simple: use boost::python::self_ns::str instead of boost::python::str. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
This is a known problem/bug. The work around is pretty simple: use boost::python::self_ns::str instead of boost::python::str. If only I had known this earlier :D Many thanks!
Btw. How would you bind copy constructor? To __copy__? If so please advise how. I tried: class_<VersionSpec_wrapper>("VersionSpec", init<const std::string &>()) .def(init<const VersionSpec &>()) but then the string constructor doesn't work: TypeError: No registered converter was able to extract a C++ reference to type std::string from this Python object of type str -- Best Regards, Piotr Jaroszynski
participants (2)
-
Piotr Jaroszynski -
Roman Yakovenko