I am trying to write a simple python extention in C. However, it keeps throwing these errors about levels of indirection when I try to compile the setup.py. I am quite a noob at C, but after error googling for some time I think there is something wrong with the pointers. Only I have no idea which pointers! Can someone please help me.
This is the C:
#include <Python.h>
static PyObject *exmod_devide(PyObject *self, PyObject *args){
double a, b;
// parse the data
if(!PyArg_ParseTuple(args, 'dd', &a, &b)){ // this is line 7, which throws the first two errors.
return NULL;
}
else{
return PyFloat_FromDouble(a/b);
}
}
static PyMethodDef module_functions[] = {
{ "devide", exmod_devide, METH_VARARGS, "Method for deviding two values" },
{ NULL, NULL, 0, NULL }
};
PyMODINIT_FUNC init_exmod(void){
return PyModule_Create(&module_functions); // this is line 21, which throws the next two errors
}
For good measure I included the setup.py
from distutils.core import Extension, setup
module1 = Extension('exmod', sources=['exmodmodule.c'])
setup(name='exmod', ext_modules=[module1,])
This is the error:
exmodmodule.c(7): warning C4047: 'function': 'const char *' differs in levels of indirection from 'int'
exmodmodule.c(7): warning C4024: 'PyArg_ParseTuple': different types for formal and actual parameter 2
exmodmodule.c(21): warning C4047: 'function': 'PyModuleDef *' differs in levels of indirection from 'PyMethodDef (*)[2]'
exmodmodule.c(21): warning C4024: 'PyModule_Create2': different types for formal and actual parameter 1