我在开发Xcode时面临这个问题。在网上找不到任何东西。我甚至不知道这个问题是与Xcode有关还是与Xcode有关。
下面是我的示例代码:
#include "myModule.h"
#include <Python/Python.h>
int Cfib(int n){
if (n<2){
return n;
}
else{
return Cfib(n-1)+Cfib(n-2);
}
}
static PyObject* fib(PyObject* self, PyObject* args){
int n;
if (!PyArg_ParseTuple(args, "i", &n)){
return NULL;
}
return Py_BuildValue("i", Cfib(n));
}
static PyObject* version(PyObject* self){
return Py_BuildValue("s", "Version 1.0");
}
static PyMethodDef myMethods[] = {
{"fib", fib, METH_VARARGS, "Calculate the fibonacci numbers."},
{"version", (PyCFunction)version, METH_NOARGS, "Tells us the version of our module."},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef myModule = {
PyModuleDef_HEAD_INIT, // Use of undeclared indentifier PyModuleDef_HEAD_INIT
"myModule",
"Fibnoacci Module",
-1,
myMethods
};
有人知道该怎么做才能让**pymoduledef_head_init**?我可以声明要克服的默认方法头定义值是什么?
或者我应该转向Linux环境进行进一步的开发吗?
谢谢。