[Interest] Compile Speed Question regarding MOC

Constantin Makshin cmakshin at gmail.com
Wed Feb 19 05:10:47 CET 2014

Look at the problem from the other side:
1) separate "moc_*.cpp" has to be compiled only during full [re]builds
or when the corresponding class' header file is changed;
2) when "moc_*.cpp" is #include-d into the implementation .cpp file,
they are both compiled at every change.

I think it's pretty obvious that (1) is better for debug/incremental
builds because changes in the implementation .cpp file don't affect the
moc-generated one, saving compilation time, while (2) is better for
release/full builds as the compiler has to do much less work parsing
headers #include-d by the class header file. And since debug builds are
done much more often than release ones, I personally prefer keeping
implementation and moc-generated code in separate files.

On 02/19/2014 02:04 AM, Michael Jackson wrote:
> I have what seems to be an obvious question/answer but the subtleties may not be what I think they are. We have a project with about 500 files most of which inherit from QObject or QWidget which means they all have moc run on them. Currently I have each moc created file compiled as a separate object which means for every class I have I am really compiling 2 files (.cpp and mocXXXX.cxx). The compile times are starting to get "up there" a bit and I was wondering what others do at this point? Do you simply do the #include "moc_MyClass.cxx" in the .cpp file of MyClass? Does that really help speed up the compile process? Before I go updating all of our source files I just wanted to get a quick sanity check for this course of action from the Qt community.
> Thanks for any advice.
> Mike Jackson

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140219/bb6e738a/attachment.sig>

More information about the Interest mailing list