On Wednesday 02 November 2011, Stephen Kelly wrote:
> On 11/02/2011 06:32 PM, David Faure wrote:
> >> > #include "foo.moc"
> >> > #include "moc_foo.cpp"
> >> >
> >> > This would have generated twice the same moc file, I think. IMO this
> >> > is really confusing.
> >
> > Well there is no reason to include both, unless you have Q_OBJECT in the
> > .cpp file too:-)
>
> I'm sure I've seen this in several places in Qt code. Grepping I found
> one in
>
> qt48/src/scripttools/debugging/qscriptenginedebugger.cpp
>
> ....
> QT_END_NAMESPACE
>
> #include "qscriptenginedebugger.moc"
>
> #include "moc_qscriptenginedebugger.cpp"
I had a look now too.
Why do they include both files here ?
Using qmake, the qscriptenginedebugger.moc is as far as I can see, for the moc
from the cpp file, while moc_qscriptenginedebugger.cpp is for the moc from the
header.
Now, why is the moc_...cpp actually #included at all ?
Isn't it enough to list the header in the qmake file, and it will be moced ?
Also, in qmake/options.cpp I see the follow code:
Option::cpp_moc_mod = "";
Option::h_moc_mod = "moc_";
...
Option::cpp_moc_ext = ".moc";
Option::h_moc_ext = ".cpp";
which seems to say that the moc file for foo.cpp will be foo.moc, while the
moc file for foo.h will be moc_foo.cpp (so it can be built as a standalone cpp
file).
Alex
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers