0

i'm attempting to use the Python.h library and receiving the following errors:

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

And when I follow the error link it takes me to (a file within the Python.h library):

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;

I'm fairly sure its a recursive include error, however I only #include <Python.h> in one of my project header files (POTWSEtupWindow.h), and the error goes away when I do not include it. I'm also using Qt, and my .pro file looks as so:

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 \

Could anyone point out what the error might be, and how it may be fixed? Likely something wrong with my .pro file. Thanks

jf192210
  • 127
  • 7
  • I believe Qt defines `slots` as a macro, expanding to nothing; to make things like `private slots:` compile. Try `#undef slots` before including `Python.h` – Igor Tandetnik Aug 22 '20 at 23:19
  • @IgorTandetnik Ohh, that makes a lot of sense. seems all instance of slots needs to be replaced with Q_SLOTS, annoying. – jf192210 Aug 22 '20 at 23:25

0 Answers0