zl程序教程

您现在的位置是:首页 >  后端

当前栏目

QT使用python时出现: error: expected unqualified-id before “;” token

PythonQt Error 出现 ID Token expected before
2023-09-14 09:07:11 时间

在使用QT Creator构建C++项目时,因为要使用Python脚本,所以要调用Python.h文件

在使用时发现会出现错误

H:\Python\Python37\include\object.h:448: error: expected unqualified-id before ‘;’ token
PyType_Slot slots; / terminated by slot==0. */

在这里插入图片描述
出现这个问题和项目本身无关 因为错误的文件在Python的include\object.h
在这里插入图片描述
应该是头文件使用出现问题

解决

后经过尝试发现#include <Python.h>要放在#include 的前面,头文件的顺序不正确也会报错。