Solved Compilation error on Q_DISABLE_COPY_MOVE
-
Disclaimer: I'm the author of the QSchematic library.
I'm using this library successfully on various platforms such as Windows, Linux & FreeBSD. Today I wanted to play around with GitHub actions as that seems to be free for open source projects.
When the CI system compiles on Ubuntu, I am getting this error pretty much every time aQ_DISABLE_COPY_MOVE
shows up:/home/runner/work/QSchematic/QSchematic/build/qschematic/qschematic-objs_autogen/HU7TA6T7T7/../../../../qschematic/items/item.h:25:9: error: ISO C++ forbids declaration of ‘Q_DISABLE_COPY_MOVE’ with no type [-fpermissive] 25 | Q_DISABLE_COPY_MOVE(Item) | ^~~~~~~~~~~~~~~~~~~
You can see the full build log here: https://github.com/simulton/QSchematic/runs/4381051342?check_suite_focus=true
Now, if I fire up an Ubuntu 21.04 or 21.10 VM I am able to build the library without any problems.
I'm having troubles understanding what's going wrong here. Does anybody have any useful insights?
-
@Joel-Bodenmann Is Qt version >= 5.13?
Is Item known type in that scope?
Is QObject included directly or indirectly? -
@jsulm Thank you for your reply.
Is Qt version >= 5.13?
I checked the GitHub Actions documentation and it would appear that
ubuntu-latest
is Ubuntu 20.04.
As far as I can tell, Ubuntu 20.04 ships with Qt 5.12.8.I take it that I need to modify the code to work with Qt 5.12 then. Would you be able to point me towards the aspect(s) relevant to this situation?
Is Item known type in that scope?
Yep.
Is QObject included directly or indirectly?
Indirectly.
-
@Joel-Bodenmann said in Compilation error on Q_DISABLE_COPY_MOVE:
Would you be able to point me towards the aspect(s) relevant to this situation?
You can disable copy/move by yourself: make copy and move constructors private. Somewhat more code to write, but independent of Qt and its version.
-
Alright - I checked the docs and
Q_DISABLE_COPY_MOVE
exists only since Qt 5.13 which leads to this problem.Thank you for your help!