July 21, 2011

ibingow ibingow
Lab Rat
31 posts

moc does not support preprocess?

 

myobject.h:

  1. #include <QObject>
  2. #define DECLARE_FUNC(type, func) \
  3.  public: type func; \
  4.  signals: type sig_##func; \
  5.  protected slots: type slot_##func;
  6.  
  7. class MyObject :public QObject {
  8.     Q_OBJECT
  9. DECLARE_FUNC(void hello())
  10. }

the i use moc to generate moc_myobject.cpp

  1. 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

  1. 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.

2 replies

July 21, 2011

peppe peppe
Ant Farmer
1028 posts

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

 Signature 

Software Engineer
KDAB (UK) Ltd., a KDAB Group company

July 21, 2011

Vijay Bhaska Reddy Vijay Bhaska Reddy
Lab Rat
399 posts

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.

 
  ‹‹ [SOLVED]QVariant in signal argument and QSignalSpy      Parsing input and performance of QRegExp ››

You must log in to post a reply. Not a member yet? Register here!