我想知道是否有人在Eclipse/Linux上使用Python的源代码?我已经将其作为makefile项目导入,它构建的很好,但是错误解析器无法正确解析某些定义,并产生大量的语义错误,例如:
Field 'Py_DECREF(argtuple)' could not be resolved
我检查了这个字段(它是Include/object.h
中的一个宏),似乎错误是因为宏使用了一个尚未定义的结构(它是在pyport.h
中定义的,它没有包含在object.h
)。我创建了以下项目:
#include <stdio.h>
#include <stdlib.h>
#include "/mnt/proj/c/Python-3.4.3/Include/pyport.h"
#include "/mnt/proj/c/Python-3.4.3/Include/object.h"
int main(void) {
PyObject po;
Py_DECREF(&po);
return 0;
}
它编译OK,错误解析器解析OK。我删除了最后两个include并将这两个文件添加到Project/Properties/Preprocessor Include Paths/CDT User Setting Entries
。Error解析器解析它OK(如果不添加这两个头,Py\u DECREF会产生“not resolved”错误)。我在Python项目中也尝试过这样做(我在CDT用户设置中添加了pyport.h
和object.h
头),但是没有纠正错误。你知道吗
为了消除这些语义错误,必须创建哪些配置设置?你知道吗
编辑1:
解析器日志中充满如下条目:
Attempt to use symbol failed: tp_dealloc in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:416
Attempt to use symbol failed: ob_type in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:417
Attempt to use symbol failed: tp_free in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:417
Attempt to use symbol failed: ob_type in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:436
Attempt to use symbol failed: tp_iternext in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:436
Attempt to use symbol failed: ob_refcnt in file /mnt/proj/c/Python-3.4.3/Python/bltinmodule.c:449
这些符号与在object.h
中定义的_typeobject
结构有关。该结构的定义使用PyObject_VAR_HEAD
宏,在同一个文件中定义如下:
#define PyObject_VAR_HEAD PyVarObject ob_base;
但是PyVarObject
结构是在PyObject_VAR_HEAD
之后定义的几行。它不会导致这些错误吗?你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐