Py++, boost and python type mismatch error

Thomas Jollans thomas at jollans.com
Thu Jun 10 11:50:02 EDT 2010


On 06/10/2010 05:15 PM, Murrgon wrote:
> I have a simple C++ library (from a dll) I am attempting to make
> accessible through bindings to python.  I used Py++ to generate some
> boost code for the library that I compiled into a pyd.  I can import the
> pyd no problem into python, but I can't seem to call the functions.
> 
> struct MM_Api
> {
>   void* pData;
> };
> 
> int declspec(dllimport) MM_Initialize( MM_Api* pApi );
> 
> I made a PyMM.pyd that has this in it.
> 
> import PyMM
> api = PyMM.MM_Api
> ret = PyMM.MM_Initialize(api)
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> Boost.Python.ArgumentError: Python argument types in
>     PyMM.MM_Initialize(Boost.Python.class)
> did not match C++ signature:
>     MM_Initialize(struct MM_Api * pApi)

Just guessing here: maybe you meant to type

import PyMM
api = PyMM.MM_Api()
ret = PyMM.MM_Initialize(api)

(initializing the MM_Api and passing the object instead of the class)

> 
> The docs for Py++ leave a lot guess work up to the user, so I don't know
> if I forgot a step, or messed something up.  Is there some glue I need
> to write/generate that will translate an instance of PyMM.MM_Api to the
> C++ version of MM_Api, and if so, is this python glue, or C/C++ glue?
> 
> Thank you
> Murrgon




More information about the Python-list mailing list