[C++-sig] Wrapping pointers
tkirke at gmail.com
Thu Apr 13 22:16:18 CEST 2006
Did you get an answer to this?
I am trying to figure out the same thing except my pointer is to an object
of a different class instead of the same class
On 4/5/06, Dominic Sacré <dominic.sacre at gmx.de> wrote:
> I'm having trouble exporting C++ pointers to Python. My code looks like
> class A
> A *p;
> class_<A>("A", init<>())
> .def_readonly("p", &A::p)
> Now every time I try to access A::p from Python I get this error:
> TypeError: No to_python (by-value) converter found for C++ type: A*
> I searched the list archives and found a message about the same issue,
> where the only suggestion was to use
> .def_readonly("p", make_getter(&A::p, return_internal_reference<1>()))
> instead, but this doesn't help either. On the contrary, this causes a
> segfault every time I use A::p (although p points to a valid object, at
> least in C++).
> So what should I do to access this pointer from Python?
> C++-sig mailing list
> C++-sig at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cplusplus-sig