Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best practice for workaround moc's inability to handle ifdef?

Best practice for workaround moc's inability to handle ifdef?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vadi2
    wrote on last edited by
    #1

    I have the following code:

    public slots:
    #if !defined(Q_OS_MACOS)
        void installOrRestartClicked(QAbstractButton* button, QString filePath);
    #endif
    
    #if !defined(Q_OS_MACOS)
    void Updater::installOrRestartClicked(QAbstractButton* button, QString filePath)
    {
    ...
    

    moc on macOS still finds this code and fails the compilation for me:

    /Users/travis/build/Mudlet/Mudlet/build/src/moc_updater.cpp:84:21: error: no member named 'installOrRestartClicked' in 'Updater'
    
            case 1: _t->installOrRestartClicked((*reinterpret_cast< QAbstractButton*(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
    
                    ~~  ^
    
    1 error generated.
    

    very annoying. One way to deal with this is to leave the declaration intact and just do:

    void Updater::installOrRestartClicked(QAbstractButton* button, QString filePath)
    {
    #if !defined(Q_OS_MACOS)
    ...
    

    How do other people workaround this moc bug?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt are you using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vadi2
        wrote on last edited by
        #3

        The latest, 5.9

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you try with ifndef ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #5

            Hi, just guessing, but to add to @SGaist, you could also try to insert an extra #include <QtCore/qglobal.h> somewhere at the top of update.h to make sure that moc really sees the that #define Q_OS_MACOS

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved