[Interest] Three-file modules vs. moc

Bernhard Lindner private at bernhard-lindner.de
Thu Aug 27 13:26:55 CEST 2020


Hi!

> > 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?

Yes. But it didn't work. Even more undefined references. 

module.inl never contains moc relevant code but module.hpp does. I guess for this to work,
moc would need to resolve the contained #include "module.hpp". It generally doesn't
resolve includes, does it?

> > 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. 

Hm. I am not sure I get it. That is a global option, right? I have a LOT of modules, each
with a different name. When adding an -f option for each of them, each moc_*.cpp file
would include all *.inl includes... which would increase compile time exponentially. I
would like to avoid that.

-- 
Best Regards,
Bernhard Lindner



More information about the Interest mailing list