Author Leslie
Recipients Leslie, benjamin.peterson, serhiy.storchaka, steve.dower, terry.reedy, vstinner
Date 2019-09-11.10:18:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Some history and explanation of this problem:

- Qt extends C++ with the following keywords:
  "slots", "signals", "emit"
- This extension is compiled with a Meta-Object-Compiler (MOC) into standard C++.
- Since code using Qt extensions (i.e. headers) generally used "mixed" with standard C++ code, "standard" compiler must be able to compile the Qt specific part, too
  -> the extension keywords are declared as empty macros (i.e. #define slots)

The consequence is that if Qt-based headers are used together with any 3rd party headers, the 3rd party code cannot contain the extension keywords (slots, signals, emit) as C/C++ tokens, because the preprocessor will "delete" them as a result of macro expansion, since the keywords are defined as empty macros.
The code won't compile because of syntax errors.

This caused bug , which was fixed in

The fix renamed the "slots" struct member in Python, thus the conflict was resolved.

Note: the Qt library is, like Python, old, and used in a huge number of projects and products. E.g. Qt is the base platform for KDE development. It's a matter of point of view, which of the two, Qt or Python should be "fixed".

In my PR I used the same solution: renaming the conflicting member.

Since this time this solution was not welcome, and obviously I'm not the first facing this issue, I was searching for another solutions.

I found that Qt has already provided a solution for this problem.

There are 2 macros: QT_NO_SIGNALS_SLOTS_KEYWORDS and QT_NO_KEYWORDS , which "turn off" defining the extension keywords as macros.
Instead the QT_SLOTS, Q_SIGNALS macros should be used, which very likely do not interfere with any 3rd party library...

Though, these are "official" Qt macros, not very well documented:  :)

So by defining QT_NO_KEYWORDS I could resolve this whole issue.

Thanks guys for your patience and attetion!
Date User Action Args
2019-09-11 10:18:49Lesliesetrecipients: + Leslie, terry.reedy, vstinner, benjamin.peterson, serhiy.storchaka, steve.dower
2019-09-11 10:18:49Lesliesetmessageid: <>
2019-09-11 10:18:49Leslielinkissue38007 messages
2019-09-11 10:18:48Lesliecreate