[Interest] Three-file modules vs. moc
Bernhard Lindner
private at bernhard-lindner.de
Mon Aug 31 18:31:17 CEST 2020
Hi!
> Add to your module.cpp:
>
> #include "moc_module.cpp"
>
> This is recommended anyway, regardless of your problem. Always #include the
> module output for your headers in your corresponding .cpp files.
I tried a variant of the above using C++17 __has_include:
#if __has_include("moc_module.cpp")
#include "moc_module.cpp"
#endif
My goal was easier module maintenance by automatic inclusion of moc-code in case moc found
relevant code in the header. Especially after reworking a module this can be easily
forgotten without the above.
Then I get this error:
No rule to make target 'moc_module.cpp', needed by 'core_module.o'. Stop.
I also tried this:
#if 0
#include "moc_module.cpp"
#endif
Same error.
It appears to me that qmake is looking for "#include "moc_module.cpp"" using some simple
regular expression which does not take any conditional compilation into account. Is this
correct?
--
Best Regards,
Bernhard Lindner
More information about the Interest
mailing list