Solved moc cpp generation fails with "No relevant classes found. No output generated."
-
Hi,
Did you re-run qmake after adding the Q_OBJECT macro ?
-
@sgaist yes, see my first post. In particular, I have tried deleting the build directory, rerunning qmake and rerunning the entire build after that.
-
Is there a verbose mode to the moc command that will elaborate on the
No relevant classes found
? -
Quite incredibly, it turned out that the moc error was because of moc parsing not being able to comprehend C++14 digit separators in the constants I had in the private section of my class! Removing the digit separators enabled the moc compilation to go through without errors! So this doesn't work:
private: const int CONST1 = 0b1000'0000;
This works:
private: const int CONST1 = 0b10000000;
I have found C++14 digit separator support to be abysmal within the Qt ecosystem, from Qt Creator to now moc. I will personally just stop using it till Qt 6 at least; hopefully it will improve by then :P
-
Opening a feature request will be a better idea, it will make the issue known to moc's developers.
-
@sgaist How/where can I do that?
-
Hi @vikramg,
Please post a link to the report here too, so others can follow later. Thanks!
-
Remove (no clean) build directory and build project.
-
@SGaist @aha_1980
Bug report here: https://bugreports.qt.io/browse/QTBUG-77421I also found other bugs filed against moc that one would need to watch out for:
- moc does not support raw string literals: https://bugreports.qt.io/browse/QTBUG-62632
- moc does not support (certain?) unicode files: https://bugreports.qt.io/browse/QTBUG-26843
These will also result in the
No relevant classes found
error. -
Thanks for sharing your additional findings !