Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Clang-Tidy fails to analyze QT project that uses Pybind11 due to reserved 'slots' keyword
Forum Updated to NodeBB v4.3 + New Features

Clang-Tidy fails to analyze QT project that uses Pybind11 due to reserved 'slots' keyword

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 2 Posters 408 Views 2 Watching
  • 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.
  • T Offline
    T Offline
    Tyler Shellberg
    wrote on last edited by
    #1

    I would like to use Clang-Tidy to lint my Cmake QT project, which I develop in QTCreator. It is a C++ project that uses Pybind11 to interface with Python code.

    Unfortunately, running Clang-tidy from within QTCreator on this project always fails with the following error:

    C:\msys64\ucrt64\include\python3.12/object.h:352:23: error: expected member name or ';' after declaration specifiers [clang-diagnostic-error]
      352 |     PyType_Slot *slots; /* terminated by slot==0. */
          |     ~~~~~~~~~~~       ^
    08:56:12: Error: Failed to analyze 1 files.
    

    Online information about this error seems sparse. But what I have dug up seems to suggest it is Python's object.h uses a reserved keyword in the form of PyType_Slot *slots;

    There is a single post suggesting that defining PYBIND11_NO_KEYWORDS can help - but I suspect this is a myth as I cannot find more than one reference to it anywhere, and searching for the keyword doesn't turn up anything in the python install directory.

    How can I get clang-tidy working in QTCreator?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tyler Shellberg
      wrote on last edited by
      #2

      It looks like consistently moving the include of Pybind11 headers before QT Headers has fixed it.

      However, this also goes for the full include tree. So if A includes B, and B includes Pybind, A should include B before including any QT Headers (QObject, QProcess, QVector, etc)

      1 Reply Last reply
      0
      • InTheBeningingI Offline
        InTheBeningingI Offline
        InTheBeninging
        wrote on last edited by
        #3

        This might help.

        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