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

moc generated source code missing include directive with 'extensionless' header file on windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.15.7
    • Build tools: moc
    • None
    • Platform manifesting the bug:
      OS: Windows 10, virtual machine inside debian bookworm host.
      python: 3.11.1
      meson: 1.0.0.rc1
      ninja: 1.11.0
      Qt: 5.15.7
    • Windows

    Description

      Problem is NOT present on debian bookworm or its predecessors or macosx big-sur, only windows 10 that I know of.

      Simple test to express bug condition:
      I have created 2 simple, duplicate header files. One is named 'mocTest' and the other is 'mocTest.h'. I did this because the lack of a header extension is relative to the bug being expressed. The bug is only present with the header file lacking the header extension. Here are the contents of the duplicate files:

      #include <QWidget>
      class AWidget : public QWidget
      {
       Q_OBJECT
       public:
         explicit AWidget(QWidget *p) : QWidget(p){}
       public Q_SLOTS:
         void testSlot();
      };

      I then took the moc command out of the ninja.build file an adapted its paths to my example. I use this command for testing the results of the moc generation. Here is that command:

      "C:/Users/Quickemu/development/vcpkg/installed/x64-windows/tools/qt5/bin\moc.exe" "--output-dep-file" "mocTest" "-o" "moc_mocTest.cpp"
      

      I will now define what I consider to be good moc output vs bad moc output. The difference is in the include of the original passed in file. Good output has the include where bad output does not. Here are samples of that:

      //good moc output.
      ...
      #include <memory>
      #include "mocTest"
      #include <QtCore/qbytearray.h>
      #include <QtCore/qmetatype.h>
      ...
      
      //bad moc output. missing include
      ...
      #include <memory>
      #include <QtCore/qbytearray.h>
      #include <QtCore/qmetatype.h>
      ...
      

      I then run 6 iterations of the command using the 2 identical headers files. I shortened the full path to moc executable for formatting. Here are those results:

      //these 3 provide good mock output. Header extension eliminates error.
      "C:/.../bin\moc.exe" "--output-dep-file" "mocTest.h" "-o" "moc_mocTest.cpp"
      "C:/.../bin\moc.exe" "--output-dep-file" "./mocTest.h" "-o" "moc_mocTest.cpp"
      "C:/.../bin\moc.exe" "--output-dep-file" ".\mocTest.h" "-o" "moc_mocTest.cpp"
      
      //these 2 produce good moc output
      "C:/.../bin\moc.exe" "--output-dep-file" "mocTest" "-o" "moc_mocTest.cpp"
      "C:/.../bin\moc.exe" "--output-dep-file" ".\mocTest" "-o" "moc_mocTest.cpp"
      
      //this produces bad moc output
      "C:/.../bin\moc.exe" "--output-dep-file" "./mocTest" "-o" "moc_mocTest.cpp"
      

      Once we use the unix directory separator on the input file without a header extension, Qt moc doesn't add the include and we get undefined type errors during compilation. I know about the moc '-f' argument and I can think of other work arounds but this is inconsistent behaviour across platforms and I think it should be considered a bug on Qt moc.

      possible related forum posts:
      mingw
      osgQt
      qt

      Attachments

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

        Activity

          People

            fabiankosmale Fabian Kosmale
            blobfish blob fish
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes