Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123229

Q_OBJECT in multi-line(?) C comment triggers automoc (but not qmake)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 6.7.0 Beta3
    • Build System: CMake
    • c07a47cbf (dev), 9932a2f64 (6.7)

      As a developer of Qt, I get an annoying qtversionnumber.h: No relevant classes found. No output generated. warning from moc when building Qt. Removing the Q_OBJECT-in-comment there makes it go away.

      It seems CMake/automoc doesn't understand that the Q_OBJECT appears in a multi-line C-style comment. This might be a CMake bug.

      Tried to add the usual qmake ignore Q_OBJECT there, but a) it isn't recognized in a C++ comment (//), only in a C-style (/**/) one, and b) trying to close and re-open the C-style comment also doesn't make it recognize it, at least not like this:

      •     {*/
        /* qmake ignore Q_OBJECT */ /*
                Q_OBJECT
        
      •     {*/
        /* qmake ignore Q_OBJECT */
        /*
                Q_OBJECT
        

      There are two solutions I can see, both require changes to automoc:

      1. Fix the parser to understand multi-line C comments and automatically ignore contained keywords (except in conjunction with qmake ignore)
      2. Allow qmake ignore also in C++ comments

      For now, I'll suppress the warning by removing the Q_OBJECT macro from the header, but leave this ticket open for the more fundamental fix.

      Note: attached minimal program demonstrates that this is an automoc problem. QMake gets this right (build with both to see difference).

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtbuildsystem Qt Build System Team
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes