[C++-sig] errors compiling Boost Python example

2012-07-05 Thread Joel Uckelman
I'm trying to compile the example from the Boost Python docs without success. hello.cpp: #include char const * const greet() { return "hello, world"; } BOOST_PYTHON_MODULE(hello_ext) { using namespace boost::python; def("greet", greet); } I have Boost 1.48, Python 2.7, a

[C++-sig] Instance ownership transfer in constructor.

2012-07-05 Thread Jani Tiainen
Hi, I'm new to python.boost library and I'm trying to use it to wrap a third party library. Everything else I've managed to get working - thanks to excellent library and lot of examples I've found around a net. Only thing I can't get working properly is instance ownership transfer in constru

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Sybren A . Stüvel
Hi Joel, On 5 July 2012 12:21, Joel Uckelman wrote: > I'm trying to compile the example from the Boost Python docs without > success. [...] > There are many ways in which you can fix this. I think the easiest one from an I'm-just-starting-so-please-give-me-a-simple-hello-world-program point of

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Joel Uckelman
Thus spake Sybren A. Stüvel: > > Hi Joel, > > On 5 July 2012 12:21, Joel Uckelman wrote: > > > I'm trying to compile the example from the Boost Python docs without > > success. [...] > > > > There are many ways in which you can fix this. I think the easiest one from > an I'm-just-starting-so-

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Sybren A . Stüvel
On 5 July 2012 13:10, Joel Uckelman wrote: > Do you know why Boost Python complains about returning a char const*? > When returning a pointer, you have to tell Boost::Python what to do with it. The most important issue is one of ownership. Once the pointer has been returned as a Python object in

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Ralf Grosse-Kunstleve
It looks like you inserted an extra const (I don't see it in the current tutorial) ... char const * const greet() { It should work if you remove it. Ralf On Thu, Jul 5, 2012 at 3:21 AM, Joel Uckelman wrote: > I'm trying to compile the example from the Boost Python docs without > success. > >

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Ralf Grosse-Kunstleve
Oops, I meant to mark the extra const with a color: char const * *const* greet() { On Thu, Jul 5, 2012 at 7:57 AM, Ralf Grosse-Kunstleve wrote: > It looks like you inserted an extra const (I don't see it in the current > tutorial) ... > > char const * const greet() { > > It should work if you r

Re: [C++-sig] errors compiling Boost Python example

2012-07-05 Thread Joel Uckelman
Thus spake Ralf Grosse-Kunstleve: > > It looks like you inserted an extra const (I don't see it in the current > tutorial) ... > > char const * const greet() { > > It should work if you remove it. Ha! You're correct. The example program was so short that I just retyped it, and I made the pointe

Re: [C++-sig] Instance ownership transfer in constructor.

2012-07-05 Thread John Reid
On 05/07/12 11:49, Jani Tiainen wrote: > Hi, > > I'm new to python.boost library and I'm trying to use it to wrap a third > party library. Everything else I've managed to get working - thanks to > excellent library and lot of examples I've found around a net. > > Only thing I can't get working pr

Re: [C++-sig] Instance ownership transfer in constructor.

2012-07-05 Thread Jani Tiainen
I want to do it another way around: Instance of Owner should hold reference to data_1 and data_2 as long as owner is alive. Now following happens: owner = Owner() data_1 = Data(owner) # data_1 ownership is transferred to owner object data_2 = Data(owner) # data_2 ownership is transferred to owner

Re: [C++-sig] Instance ownership transfer in constructor.

2012-07-05 Thread Holger Brandsmeier
Jani, ok what you want to do is quite a lot more intrusive, so you need some more involved methods, but it should be possible. I would do it by noting the following - data_1 is published to python as a boost::shared_ptr (default holder type) - usually it is difficult for a class member function,

Re: [C++-sig] Instance ownership transfer in constructor.

2012-07-05 Thread Jani Tiainen
Hi, I'm still strugling with this whole thingy so I came up with more concrete example I'm trying to achieve: http://pastebin.com/dVRfT56x And in python code I do like this: owner = Owner() data = Data(owner) After script is finished I get warning message that Data destructor shouldn't be