[C++-sig] errors compiling Boost Python example
Sybren A. Stüvel
sybren at stuvel.eu
Thu Jul 5 13:15:42 CEST 2012
On 5 July 2012 13:10, Joel Uckelman <uckelman at nomic.net> 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 the Python world, and that object goes out
of scope, what should happen with the pointer? Is it owned by Python and
should the pointed-to memory be deallocated too? Or was it still owned by
the function that returned it? This is what you have to tell Boost::Python
before it allows you to return pointers. And this is also why I looked for
a solution that didn't involve pointers - much easier to understand as a
first example.
> It's a strange thing to have for the first example in the docs if it won't
> compile.
I agree. Personally I can't do anything about that, though.
--
Sybren A. Stüvel
http://stuvel.eu/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20120705/925e1b09/attachment-0001.html>
More information about the Cplusplus-sig
mailing list