Moc does not support preprocess?



  • myobject.h:
    @
    #include <QObject>
    #define DECLARE_FUNC(type, func)
    public: type func;
    signals: type sig_##func;
    protected slots: type slot_##func;

    class MyObject :public QObject {
    Q_OBJECT
    DECLARE_FUNC(void hello())
    }@

    the i use moc to generate moc_myobject.cpp
    @moc $DEFINES $INCPATH myobject.h -o moc_myobject.cpp@

    i find that no signal and slot code in moc_myobject.cpp

    but if i use
    @cpp $DEFINES $INCPATH myobject.h |moc >moc_myobject.cpp@
    then this moc_myobject.cpp is what i want.

    So i guess moc can not support preprocess well. If it is true, I think it's better to change the default rule to generate moc_xxx.cpp in Makefile.



  • You're correct: moc does not expand defines. I'm not sure however about what you're trying to accomplish with that macro.



  • I was reading some moc related material today, and this was one point that I came across..

    http://doc.qt.nokia.com/latest/moc.html

    see under "Limitations" section.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.