我有一个qt应用程序,我想在其中实现python解释器,以便我可以使用python脚本扩展它.虽然这适用于常规C++应用程序,包括Python.h,即使对于大多数简单,空Qt4项目总是会导致:
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I/usr/include/python3.2mu -I. -o main.o main.cpp In file included from /usr/include/python3.2mu/Python.h:8:0, from main.cpp:16: /usr/include/python3.2mu/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default] /usr/include/features.h:164:0: note: this is the location of the previous definition /usr/include/python3.2mu/pyconfig.h:1204:0: warning: "_XOPEN_SOURCE" redefined [enabled by default] /usr/include/features.h:166:0: note: this is the location of the previous definition In file included from /usr/include/python3.2mu/Python.h:67:0, from main.cpp:16: /usr/include/python3.2mu/object.h:402:23: error: expected unqualified-id before ‘;’ token make: *** [main.o] Error 1
我只在我的.pro文件中实现了这个:
INCLUDEPATH + ="/ usr /include/python3.2"
现在我随时都可以
#include
在任何.h文件中,它使它无法构建.这是为什么?
注意:这一切都与python 2.7完美配合,只是python 3x不起作用
编辑:我想通了,当我将Python.h作为第一个文件包含在Qt包含之前,它可以工作,这是python中的一个错误吗?他们是否缺少一些安全卫士?