On Tuesday, 27 de September de 2011 12:54:44 Joerg Bornemann wrote:
> On Mon, 2011-09-26 at 18:16 +0200, ext Oswald Buddenhagen wrote:
> > no. including a file does *not* add a dependency of the "includer" on the
> > "includee". dependencies are always from generated artifacts to their
> > sources. the _moc.h is generated from the .h, so it has a dependency on
> > it (and the files it includes; excluding the _moc.h's would be qmake's
> > responsibility - it can do that, because it knows that the inclusion of
> > the generated files themselves does not change what will go into the
> > generated files). the .o is generated from the .cpp and the .h and the
> > _moc.h, so it has dependencies on them.
> 
> And we already have such a case with our current moc:
> 
> --myobject.cpp--
> class MyObject :public QObject {
>     Q_OBJECT
> // ...
> };
> 
> #include "myobject.moc"
> ----------------
> 
> If includes would add dependencies then we would have a circle:
> 
> myobject.cpp -> myobject.moc -> myobject.cpp

I spent half an hour yesterday trying to wrap my brain around what Oswald had 
said. I was writing a reply disproving what he had said and I ended up proving 
he was right instead. Since it was so convoluted with my thought process, I 
discarded it and didn't send.

My problem was thinking of the source file as a target in make. That isn't the 
case: neither myobject.cpp nor myobject.h are targets. They simply exist as 
files.

myobject.o is a target. That's how your loop above breaks. The make rules are:

myobject.o: myobject.cpp myobject.moc
myobject.moc: myobject.cpp

I got confused because in the case of a header, there is no myobject.o. 
Instead, the dependency of myobject.h on myobject.moc.h becomes an indirect 
dependency for the next target using the header. That is, if myotherobject.cpp 
includes myobject.h, it becomes:

myotherobject.o: myobject.h myobject.moc.h \
        myotherobject.h myotherobject.cpp myotherobject.moc

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to