Boost logo

Boost Users :

Subject: Re: [Boost-users] passing pointers from python
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2010-03-18 01:57:45


On Wed, Mar 17, 2010 at 9:39 PM, hitesh dhiman
<hitesh.dhiman.1988_at_[hidden]> wrote:
> Hi all,
> i'm trying to wrap c++ functions that have pointer variables. The test
> example i'm using is shown below:
> int World::addition(int* a, int* b)
> {
> int z = *a + *b;
> return z;
> }
> Now, i defined it in my wrapper as :
> .def("addition", &World::addition)
> My code compiles, but when I try to execute it from python, i get this
> error:
> Python Argument types in World.Addition(World, int, int) did not match C++
> signature: addition(class World {lvalue}, int* , int*)
> The problem is, how to get hold of a pointer in python? Or is there a
> workaround to define the function differently in the wrapper file?

Perhaps try references (as that function should be anyway considering
it directly dereferences both)?

Or add a wrapper that uses references instead if you cannot alter the
original function?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net