为什么必须首先将python 3.2的Python.h与Qt4一起包含在内

 爱走了我来了two_537 发布于 2023-02-13 17:37

我有一个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中的一个错误吗?他们是否缺少一些安全卫士?

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有