Reputation: 589
I want to write a wrapper for my C function as I want to call it from python code.So my wrapper function is
static PyObject* my_func_wrapper(PyObject *self, PyObject *args)
{
PyObject* obj_Ptr = my_func();
return Py_BuildValue('O', obj_Ptr);
}
My C my_func() has no params, and return MyClass pointer converted to (void *).
When I run my setup.py script I'm getting this
warning: passing argument 1 of ‘Py_BuildValue’ makes pointer from integer without a cast [-Wint-conversion]
Py_BuildValue('O', obj_Ptr);
and when I call my_func_wrapper from python I'm getting Seg.Fault Error in return line.
How can I fix this?
Thanks.
Upvotes: 0
Views: 577
Reputation: 2122
Here is the prototype of Py_BuildValue:
PyObject *Py_BuildValue(char *format, ...);
So the first argument should be "O" and not 'O'.
I'm not sure about you second arg either : you are using my_func() result instead of getting a pointer to this function.
Upvotes: 1