Py++, boost and python type mismatch error

Murrgon murrgon at hotmail.com
Thu Jun 10 11:15:12 EDT 2010


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)

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