Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. #include<Python.h>: Error in included file
QtWS25 Last Chance

#include<Python.h>: Error in included file

Scheduled Pinned Locked Moved Unsolved C++ Gurus
c++ gurupythonc++
8 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Factao
    wrote on last edited by
    #1

    I want to run an embedded python script on Qt, but my compiler seem to find a lot of error inside Python.h (more specifically, inside Pyobject.h and sliceobject.h. It might be something called slots, which appeared to be flagged as the Qt slots or it might be a bunch of missing semicolon or parenthesis.

    Since these files are from the official python distribution and the include files of the pythonXX.lib library, I would rather not modify them, since this is supposed to be functional.

    Would there be a way to prevent my compiler from flagging error within these files?

    jsulmJ 1 Reply Last reply
    0
    • F Factao

      I want to run an embedded python script on Qt, but my compiler seem to find a lot of error inside Python.h (more specifically, inside Pyobject.h and sliceobject.h. It might be something called slots, which appeared to be flagged as the Qt slots or it might be a bunch of missing semicolon or parenthesis.

      Since these files are from the official python distribution and the include files of the pythonXX.lib library, I would rather not modify them, since this is supposed to be functional.

      Would there be a way to prevent my compiler from flagging error within these files?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Factao If the problem is the conflict between Python "slots" and Qt "slots" you can set QT_NO_KEYWORDS (see https://github.com/pytorch/pytorch/issues/19405)

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Factao If the problem is the conflict between Python "slots" and Qt "slots" you can set QT_NO_KEYWORDS (see https://github.com/pytorch/pytorch/issues/19405)

        F Offline
        F Offline
        Factao
        wrote on last edited by
        #3

        @jsulm Thank you!

        I am also getting a lot of syntax error in this line:

        PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length, Py_ssize_t *start,
                                           Py_ssize_t *stop, Py_ssize_t *step);
        Py_DEPRECATED(3.7)
        PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
                                             Py_ssize_t *start, Py_ssize_t *stop,
                                             Py_ssize_t *step,
                                             Py_ssize_t *slicelength);
        

        These are the line 43 to 49 of sliceobject.h. There apparently is a lot of missing parenthesis and semicolon before a 'constant', but there isn't any apparent conflicting keyword.

        JonBJ 1 Reply Last reply
        0
        • F Factao

          @jsulm Thank you!

          I am also getting a lot of syntax error in this line:

          PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length, Py_ssize_t *start,
                                             Py_ssize_t *stop, Py_ssize_t *step);
          Py_DEPRECATED(3.7)
          PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
                                               Py_ssize_t *start, Py_ssize_t *stop,
                                               Py_ssize_t *step,
                                               Py_ssize_t *slicelength);
          

          These are the line 43 to 49 of sliceobject.h. There apparently is a lot of missing parenthesis and semicolon before a 'constant', but there isn't any apparent conflicting keyword.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Factao
          Since there is nothing wrong in the C++ PySlice_... declarations, I would assume the macros (PyAPI_FUNC(), Py_DEPRECATED()) are not defined when it hits these lines, for whatever reason....

          F 2 Replies Last reply
          0
          • JonBJ JonB

            @Factao
            Since there is nothing wrong in the C++ PySlice_... declarations, I would assume the macros (PyAPI_FUNC(), Py_DEPRECATED()) are not defined when it hits these lines, for whatever reason....

            F Offline
            F Offline
            Factao
            wrote on last edited by
            #5

            @JonB They seem defined for me. Here is what it look like and what their definition seem to be.alt text

            alt text

            https://ibb.co/Rb2S3YW

            JonBJ 1 Reply Last reply
            0
            • F Factao

              @JonB They seem defined for me. Here is what it look like and what their definition seem to be.alt text

              alt text

              https://ibb.co/Rb2S3YW

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Factao
              Those may only be "errors/warnings" coming from the IDE's code completion plugin, which can get things wrong. Do you get those errors when you actually compile?

              F 1 Reply Last reply
              0
              • JonBJ JonB

                @Factao
                Since there is nothing wrong in the C++ PySlice_... declarations, I would assume the macros (PyAPI_FUNC(), Py_DEPRECATED()) are not defined when it hits these lines, for whatever reason....

                F Offline
                F Offline
                Factao
                wrote on last edited by
                #7

                @JonB My apologies, I can't read. Here are the definition. I am also getting a 'not throw' on PySlice_GetIndices and PySlice_GetIndicesEx, with a message that my beginner brain cannot process.
                alt text
                alt text
                alt text

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Factao
                  Those may only be "errors/warnings" coming from the IDE's code completion plugin, which can get things wrong. Do you get those errors when you actually compile?

                  F Offline
                  F Offline
                  Factao
                  wrote on last edited by
                  #8

                  @JonB I'm a little bit rusted in C++ (I do not remember if compiling and building are the same), but I am getting these error when I am building. I havent really done more.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved