Python.h的递归包含导致编译错误

问题描述

我正在尝试使用Python.h库并收到以下错误:

C2059: Syntax error ';'
C2238: unexpected token(s) preceding ';'

当我点击错误链接时,它带我到(Python.h库中的文件):

typedef struct{
    const char* name;
    int basicsize;
    int itemsize;
    unsigned int flags;
    PyType_Slot *slots; /* terminated by slot==0. */ <---- THIS LINE SUPPOSEDLY HAS AN ERROR
} PyType_Spec;

我相当确定它是一个递归包含错误,但是我仅#include <Python.h>位于我的一个项目头文件(POTWSEtupWindow.h)中,而当我不包含它时,该错误就会消失。我也在使用Qt,我的.pro文件看起来像这样:

QT       += core gui

greaterThan(QT_MAJOR_VERSION,4): QT += widgets

CONFIG += c++11

DEFINES += QT_DEPRECATED_WARNINGS

INCLUDEPATH += C:/python/include

LIBS += "C:/python/libs" -lpython38

SOURCES += \
    button.cpp \
    fancyslider.cpp \
    main.cpp \
    mainwindow.cpp \
    potwsetupwindow.cpp \
    startwindow.cpp \
    questionbox.cpp \

HEADERS += \
    button.h \
    fancyslider.h \
    mainwindow.h \
    potwsetupwindow.h \
    startwindow.h \
    questionbox.h \

谁能指出错误可能是什么,以及如何解决?我的.pro文件可能有问题。谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)