在win32上编译python ast.c时出现的问题
我已经下载了提取,在发出此命令后:在win32上编译python ast.c时出现的问题,python,compilation,Python,Compilation,我已经下载了提取,在发出此命令后: D:\sources\Python-2.7.1>gcc -c -I.\Include -I.\PC -I.\Python .\Python\Python-ast.c .\Python\Python-ast.c:464: error: initializer element is not constant .\Python\Python-ast.c:464: error: (near initialization for 'AST_type.ob_type
D:\sources\Python-2.7.1>gcc -c -I.\Include -I.\PC -I.\Python .\Python\Python-ast.c
.\Python\Python-ast.c:464: error: initializer element is not constant
.\Python\Python-ast.c:464: error: (near initialization for 'AST_type.ob_type')
有关守则:
static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) //this is line 464
"_ast.AST",
sizeof(PyObject),
0,
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
PyObject_GenericSetAttr, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
ast_type_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)ast_type_init, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
PyObject_Del, /* tp_free */
};
我正在使用:
指定的目录包含所需的所有包含项。为什么会这样?Python ast.c中的代码看起来像是标准的c
感谢您的帮助Windows上的Python希望使用MSVC编译。为其设置了
#define
等。他们可能会查找由MSVC和(如果我没记错的话)mingw32定义的宏WIN32或其他东西。由于您使用的是mingw而不是MSVC进行编译,这可能是问题的一部分
我还将找出PyVarObject\u HEAD\u INIT
的定义位置,并尝试找出它放在该行上的哪些内容可能导致错误
gcc version 4.4.1 (TDM-1 mingw32)