Score:1

Syntax error in object.h file from python3.10-dev package

ba flag

I am writing a code to edit Sqlite database from c++ and then using PyBind11 to use the program with python. I installed PyBind11, built it till here no issue but when I am building the code it shows an error:

/usr/include/python3.10/object.h:227: error: expected unqualified-id before ‘;’ token
In file included from /usr/include/python3.10/Python.h:74,
                 from /usr/local/include/pybind11/detail/common.h:266,
                 from /usr/local/include/pybind11/attr.h:13,
                 from /usr/local/include/pybind11/detail/class.h:12,
                 from /usr/local/include/pybind11/pybind11.h:13,
                 from /media/raghav/Sector 16/core/database.cpp:21:
/usr/include/python3.10/object.h:227:23: error: expected unqualified-id before ‘;’ token
  227 |     PyType_Slot *slots; /* terminated by slot==0. */
      |                       ^

Else, my code works fine but I am stuck at this thing. I am using the following things:

  1. Ubuntu
  2. CMake 3.24.2
  3. Qt Creator 10
  4. Python 3.10.6

Please help me out. Thanks in advance

hr flag
I suspect the issue is similar to [expected unqualified-id before ‘;’ token](https://stackoverflow.com/questions/7292558/expected-unqualified-id-before-token) i.e. a pre-processor directive (perhaps from an earlier Qt header in your code) that is stomping on the PyType_Spec struct's `slots` variable name.
David avatar
cn flag
Why no version info for Ubuntu, it needs to be there.
Score:0
ba flag

Thanks for you support. The solution was to import pybind11 before importing Qt modules and using the #define PYBIND11_NO_KEYWORDS

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.