On Sunday 06 November 2011, Thiago Macieira wrote:
> On Sunday, 6 de November de 2011 18:42:42 Alexander Neundorf wrote:
> > 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 ?
> 
> Why not?
> 
> > Isn't it enough to list the header in the qmake file, and it will be
> > moced ?
> 
> That is correct. That's what creates the moc_....cpp file.
> 
> If the file is #included by anything, it isn't added to the list of sources
> to be compiled.

So compiling is a bit faster.
Any other reasons/advantages ?

Am I right that with qmake foo.moc is always generated from the cpp file, 
while moc_foo.cpp is always generated from the header 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

Reply via email to