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

moc parse error on combination of namespace, enum and include

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.15.2
    • Build tools: moc
    • None
    • Qt 5.15.2, VS2019 16.9.6, Win10.
    • Windows

      Compile the attached project to get the error reported by moc: Parse error at "...(file name with path)..."

      The project can be compiled successfully with 5.12.5.  Not tested with other versions.

       

      Basically, this is the pattern to trigger the bug:

      #pragma once

      namespace myNameSpace{

        typedef enum _MY_ENUMS_ {

          #include "MyNames.h"

        }eMY_ENUMS;

        class QMyClass : public QObject

        {

          Q_OBJECT

          // other contents

        };

      } // namespace

       

      And this is the contents of MyNames.h:

      myEnum1,
      myEnum2,

       

      Notice the comma after myEnum2.  The moc will be a success if the comma is removed.  The tricky part is, if the contents is placed directly inside enum, without using #include, it will also be a success even with the comma after myEnum2.

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

            fabiankosmale Fabian Kosmale
            bob_dong bob dong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes