ich habe das Problem, dass beim Erstellen meines c-Moduls, gcc den folgenden Fehler spuckt: error: ‘METH_VARAGS’ undeclared here (not in a function)!
python-dev ist installiert, die Datei Python.h kann vom compiler auch gefunden werden. Warum kenn er den FLAG METH_VARAGS nicht? wo sollte der deklariert sein? ersetzte ich METH_VARAGS durch 0 wird erfolgreich kompelliert. aber das Argumente-Parsen klappt nicht, denn das korrente Handling bestimmt ja dieser FLAG.
hier der C-Code
Code: Alles auswählen
#include <Python.h>
static PyObject* py_rand2DSample(PyObject* self, PyObject* args)
{
int n;
if (! PyArg_ParseTuple(args, "i", &n))
return NULL;
return Py_BuildValue("i", n);
}
static PyMethodDef myCForPython_methods[] = {
{"rand2DSample", py_rand2DSample, METH_VARAGS},
{NULL, NULL}
};
void initmyCForPython()
{
(void) Py_InitModule("myCForPython", myCForPython_methods);
}
Grüße