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

MOC cannot parse nested inline namespace (Parse error at "::")

    XMLWordPrintable

Details

    • Linux/Wayland
    • 5222df2be7 (qt/qtbase/dev) 5222df2be7 (qt/tqtc-qtbase/dev) 430047ecc8 (qt/tqtc-qtbase/6.2) c2750da343 (qt/qtbase/6.4) c2750da343 (qt/tqtc-qtbase/6.4)

    Description

      Attempting to build the following:

      #include <QObject>
      
      namespace A::inline B {}
      
      class Foo : public QObject { 
          Q_OBJECT 
      };

       will fail at the auto MOC step with the message:

      foo.h:3:1 error: Parse error at "::"

       Using:

      #ifndef Q_MOC_RUN
      namespace A::inline B {}
      #endif

      around the offending namespace line allows the auto MOC step to complete.

       

      It would appear the MOC is not able to handle c++20 nested inline namespace. (See syntax (9) here:  https://en.cppreference.com/w/cpp/language/namespace)

       

      Use case of interest

      The problem was discovered while trying out the mp-units library (https://github.com/mpusz/units) which as of its 0.7.0 release does use the nested inline namespace feature. (For instance, here: https://github.com/mpusz/units/blob/v0.7.0/src/systems/isq-natural/include/units/isq/natural/acceleration.h)

      While this can be deactivated with a macro in this case (i.e. UNITS_NO_ALIASES), nested inline namespace are still something that should probably be supported by the MOC.

       

      Attachments

        Issue Links

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

          Activity

            People

              fabiankosmale Fabian Kosmale
              simon_gamache Simon Gamache
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes