[Interest] Q_OS_ANDROID macro

Jürgen Hunold jhunold at gmx.eu
Wed Feb 4 20:11:57 CET 2015


Hi Nuno,

Am Mittwoch, 4. Februar 2015, 18:52:52 schrieb Nuno Santos:
> I have found a workaround for the problem. I have included the
> BonjourRecord  header because it doesn't have any dependency on
> dns_sd.h. This way I can safely declare the slots on the header. The
> main problem here is that the moc_ doesn't know about Q_OS_ANDROID when
> it is generated which will generate entry for the slots that shouldn't
> be there.
> 
> public slots:
>      #ifndef Q_OS_ANDROID
>      void recordAdded(const BonjourRecord &record);
>      void recordRemoved(const BonjourRecord &record);
>      void bonjourRecordResolved(const QHostInfo &hostInfo, int port);
>      #endif

#defining QT_NO_KEYWORDS would make the failure easier to spot:

 public Q_SLOTS:
    #ifndef Q_OS_ANDROID
      void recordAdded(const BonjourRecord &record);

>From the error:

> Anyway, as you requested, this is the complete output of the error:
> 
> .build\moc\moc_LKBridgeBrowser.cpp
> .build\moc\moc_LKBridgeBrowser.cpp: In static member function 'static
> void LKBridgeBrowser::qt_static_metacall(QObject*, QMetaObject::Call,
> int, void**)':
> .build\moc\moc_LKBridgeBrowser.cpp:126:21: error: 'class
> LKBridgeBrowser' has no member named 'recordAdded'
>           case 6: _t->recordAdded((*reinterpret_cast< const
> BonjourRecord(*)>(_a[1]))); break;
>                       ^
> .build\moc\moc_LKBridgeBrowser.cpp:127:21: error: 'class
> LKBridgeBrowser' has no member named 'recordRemoved'
>           case 7: _t->recordRemoved((*reinterpret_cast< const
> BonjourRecord(*)>(_a[1]))); break;
>                       ^
> .build\moc\moc_LKBridgeBrowser.cpp:128:21: error: 'class
> LKBridgeBrowser' has no member named 'bonjourRecordResolved'
>           case 8: _t->bonjourRecordResolved((*reinterpret_cast< const
> QHostInfo(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;

Just an educated guess: It might be that the moc ignores preprocessor #define s 
_after_ it has parsed the slot/Q_SLOT keyword/macro.

Did you try if  #ifndef Q_OS_ANDROID around the "public slots:" works?

Yours,

Jürgen
-- 
* Dipl.-Math. Jürgen Hunold  ! 
* voice: ++49 4257 300       ! Fährstraße 1
* fax  : ++49 4257 300       ! 31609 Balge/Sebbenhausen
* jhunold at gmx.eu             ! Germany



More information about the Interest mailing list