Hi Giuseppe, > This trick is used in several places in Qt itself (look for "includemoc" > in commits). Not only it helps build times but also it produces slightly > better code overall.
Could you please elaborate what exactly do you mean under 'better code'? How does including the xxx_moc.cpp affect the code generation by moc? If moc decides to generate a better code when included explicitly in a cpp file, why can't it generate the same better code otherwise? Is there a technical reason for it? Thanks! Cheers Dmitriy On Fri, Dec 6, 2019 at 9:49 AM Giuseppe D'Angelo via Interest < interest@qt-project.org> wrote: > Il 06/12/19 09:42, Uwe Rathmann ha scritto: > > Something you can try is to include the moc file at the end of your cpp > > file. This can be done like this: > > > > #include "moc_XYZ.cpp" > > > > This type of construction is at least supported by qmake. > > > > This does not reduce the number of moc runs, but it reduces the number > > of compiler runs. As a rule of thumb for not too large classes I would > > expect, that ~50% of the compile time is spent inside the Qt headers and > > by including the moc file the overall compile time goes down by 33% as > > the headers need to be processed only once. > > This trick is used in several places in Qt itself (look for "includemoc" > in commits). Not only it helps build times but also it produces slightly > better code overall. > > HTH, > -- > Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer > KDAB (France) S.A.S., a KDAB Group company > Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com > KDAB - The Qt, C++ and OpenGL Experts > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > https://lists.qt-project.org/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest