[Development] Announcing moc_combine

Oswald Buddenhagen oswald.buddenhagen at qt.io
Mon May 30 11:16:00 CEST 2016


On Mon, May 30, 2016 at 10:19:38AM +0200, Marc Mutz wrote:
> On Sunday 29 May 2016 18:05:07 Thiago Macieira wrote:
> > I've just pushed a feature[1] to moc that makes it process multiple headers
> > at  the same time, producing only one output file
> 
> Separate compilation is not how I would recommend to use moc-generated files. 
> I'd recommend to always include the moc file in the corresponding cpp file. 
>
i agree that the idea to bulk-compile mocs is somewhat backwards.

however, manual includemocs are somewhat annoying, and in fact the need
to include the moc when using Q_OBJECT in a .cpp file is one of the most
common reasons for puzzling error messages (something about a missing
vtable ... ?!?!).

an idea would be auto-wrapping sources into generated files that
include the actual source and the moc. but that might be a bit tough to
implement with qmake, and the build artifacts would look a bit weird
(particularly relevant for debugging).

the next idea would be implementing moc inside the compiler itself,
which is possible with at least clang and gcc nowadays.

the last idea is doing away with moc entirely, at the cost of somewhat
uglier macros, and actually working c++11/14 support in the compiler.

"incidentally", olivier has more-or-less working solutions based on the
latter two ideas.

> That gives the compiler the whole picture and enables better optimisation[1] 
> and error checking[2,3].
> 
> Thanks,
> Marc
> 
> [1] https://codereview.qt-project.org/152423
> [2] https://codereview.qt-project.org/153309
> [3] https://codereview.qt-project.org/153321
> 
> -- 
> Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
> KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
> Tel: +49-30-521325470
> KDAB - Qt, C++ and OpenGL Experts
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list