> -----Ursprüngliche Nachricht----- > Von: Interest <interest-boun...@qt-project.org> Im Auftrag von Bernhard > Lindner > Gesendet: Mittwoch, 26. August 2020 21:41 > An: interest@qt-project.org > Betreff: [Interest] Three-file modules vs. moc > > Hi! > > Currently I am facing a problem with a Qt Creator managed Qt 5 project. > > The projects consists of a lot of modules and implements a special but useful > file concept. Each module has 3 files: > module.hpp - Public types, macros and declarations > module.inl - Template function definitions, constexpr and inline function > definitions > module.cpp - All other definitions > module.cpp includes module.inl and module.inl includes module.hpp. > > I added all .hpp file names to the .pro file using Qt Creator. All moc > relevant > .hpp files are parsed fine by moc and a moc_module.cpp file is generated for > each module as usual.
Have you tried adding the .inl files to HEADERS instead? > Unfortunately the moc_module.cpp files includes module.hpp only, since > module.inl are unknown to moc. > So all function definitions from moc_module.inl are unknown during > compilation of moc_module.cpp and I get undefined reference linker errors > (e.g. for property related setters called in the moc_module.cpp code). You can let moc add additional includes in it's output via -f<file> argument, Custom options to moc can be set in qmake via QMAKE_MOC_OPTIONS. > Maybe I could use a lot of Q_MOC_RUN preprocessor conditions to work > around but that would pollute the code awfully. > > How can I solve this problem on the moc side? Is there a way to tell moc via > the .pro project on a per-module basis to include module.inl instead of (or > along with) module.inl in moc_module.cpp? See above. Either let moc directly parse module.inl, instead of module.hpp. Or let the generated moc file include module.inl by setting e.g. QMAKE_MOC_OPTIONS=-fmodule.inl Regards Kai _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest