我正在使用eclipse和cygwin gcc编译器。尝试将Python.h用于我的C程序,但在编译时遇到这些错误。有什么想法吗?
In file included from C:/Python27/include/python.h:86,
from ../src/EmbeddedPython.c:13:
C:/Python27/include/intobject.h:45: error: parse error before "PyInt_AsUnsignedLongLongMask"
C:/Python27/include/intobject.h:45: warning: type defaults to `int' in declaration of `PyInt_AsUnsignedLongLongMask'
C:/Python27/include/intobject.h:45: warning: data definition has no type or storage class
In file included from C:/Python27/include/python.h:88,
from ../src/EmbeddedPython.c:13:
C:/Python27/include/longobject.h:49: warning: parameter names (without types) in function declaration
C:/Python27/include/longobject.h:51: error: parse error before "PyLong_AsLongLong"
C:/Python27/include/longobject.h:51: warning: type defaults to `int' in declaration of `PyLong_AsLongLong'
C:/Python27/include/longobject.h:51: warning: data definition has no type or storage class
C:/Python27/include/longobject.h:52: error: parse error before "PyLong_AsUnsignedLongLong"
C:/Python27/include/longobject.h:52: warning: type defaults to `int' in declaration of `PyLong_AsUnsignedLongLong'
C:/Python27/include/longobject.h:52: warning: data definition has no type or storage class
C:/Python27/include/longobject.h:53: error: parse error before "PyLong_AsUnsignedLongLongMask"
C:/Python27/include/longobject.h:53: warning: type defaults to `int' in declaration of `PyLong_AsUnsignedLongLongMask'
C:/Python27/include/longobject.h:53: warning: data definition has no type or storage class
C:/Python27/include/longobject.h:54: error: parse error before "PyLong_AsLongLongAndOverflow"
C:/Python27/include/longobject.h:54: warning: type defaults to `int' in declaration of `PyLong_AsLongLongAndOverflow'
C:/Python27/include/longobject.h:54: warning: data definition has no type or storage class
make: *** [src/EmbeddedPython.o] Error 1
答案 0 :(得分:2)
我不知道这是否会对你有帮助,但是在OS X上使用gcc来编译带有嵌入式Python的C程序我必须链接到Python库。例如,从我编译的命令行:
gcc python_test.c -lpython2.7 -o python_test
其中-l是标志,python2.7是我的Python库文件夹。