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. QTEST_APPLESS_MAIN macro bug
Forum Updated to NodeBB v4.3 + New Features

QTEST_APPLESS_MAIN macro bug

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.1k Views
  • 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.
  • G Offline
    G Offline
    Gabriel_22
    wrote on last edited by Gabriel_22
    #1

    I created a new project by selecting New Project -> Other Project -> Auto Test Project

    The file looked like this:

    #include <QtTest>
    
    // add necessary includes here
    
    class MyClass : public QObject
    {
        Q_OBJECT
    
    public:
        MyClass ();
        ~MyClass ();
    
    private slots:
        void test_case1();
    
    };
    
    MyClass::MyClass ()
    {
    
    }
    
    MyClass::~MyClass ()
    {
    
    }
    
    void MyClass::test_case1()
    {
    
    }
    
    QTEST_APPLESS_MAIN(MyClass )
    
    #include "tst_myclass.moc"
    

    But there was an error in the line: QTEST_APPLESS_MAIN(MyClass)

    *tst_delete.cpp:33:1: error: cannot initialize a parameter of type 'const char ' with an rvalue of type 'int'
    qtest.h:345:5: note: expanded from macro 'QTEST_APPLESS_MAIN'
    qtest.h:336:74: note: expanded from macro 'QTEST_SET_MAIN_SOURCE_PATH'
    6:30: note: expanded from here
    qtestcase.h:283:75: note: passing argument to parameter 'builddir' here

    Why does this error exist right at the project creation?
    Is there a way to fix it or avoid it?

    I am using Qt Creator 4.9.0 and Qt 5.10.0

    aha_1980A 1 Reply Last reply
    0
    • G Gabriel_22

      I created a new project by selecting New Project -> Other Project -> Auto Test Project

      The file looked like this:

      #include <QtTest>
      
      // add necessary includes here
      
      class MyClass : public QObject
      {
          Q_OBJECT
      
      public:
          MyClass ();
          ~MyClass ();
      
      private slots:
          void test_case1();
      
      };
      
      MyClass::MyClass ()
      {
      
      }
      
      MyClass::~MyClass ()
      {
      
      }
      
      void MyClass::test_case1()
      {
      
      }
      
      QTEST_APPLESS_MAIN(MyClass )
      
      #include "tst_myclass.moc"
      

      But there was an error in the line: QTEST_APPLESS_MAIN(MyClass)

      *tst_delete.cpp:33:1: error: cannot initialize a parameter of type 'const char ' with an rvalue of type 'int'
      qtest.h:345:5: note: expanded from macro 'QTEST_APPLESS_MAIN'
      qtest.h:336:74: note: expanded from macro 'QTEST_SET_MAIN_SOURCE_PATH'
      6:30: note: expanded from here
      qtestcase.h:283:75: note: passing argument to parameter 'builddir' here

      Why does this error exist right at the project creation?
      Is there a way to fix it or avoid it?

      I am using Qt Creator 4.9.0 and Qt 5.10.0

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @Gabriel_22,

      I cannot reproduce your problem on Ubuntu 18.04 with Creator 4.9.0 and Qt 5.12.3.

      Which operating system are you using? And which compiler?

      Regards

      Qt has to stay free or it will die.

      G 1 Reply Last reply
      2
      • aha_1980A aha_1980

        Hi @Gabriel_22,

        I cannot reproduce your problem on Ubuntu 18.04 with Creator 4.9.0 and Qt 5.12.3.

        Which operating system are you using? And which compiler?

        Regards

        G Offline
        G Offline
        Gabriel_22
        wrote on last edited by
        #3

        Hello @aha_1980,
        Im using windows 10 and mingw 32bits compiler

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Please show use the compiler output - there must be QT_TESTCASE_BUILDDIR given as a define to the compiler afair.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          G 1 Reply Last reply
          3
          • Christian EhrlicherC Christian Ehrlicher

            Please show use the compiler output - there must be QT_TESTCASE_BUILDDIR given as a define to the compiler afair.

            G Offline
            G Offline
            Gabriel_22
            wrote on last edited by
            #5

            Hello @Christian-Ehrlicher,

            Here is the compiler output:

            12:56:31: Running steps for project AutoTest...
            12:56:31: Starting: "C:\Qt_new\5.6.3\mingw49_32\bin\qmake.exe" C:\Users\Luis\Documents\AutoTest\AutoTest.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
            12:56:33: The process "C:\Qt_new\5.6.3\mingw49_32\bin\qmake.exe" exited normally.
            12:56:33: Starting: "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" -f C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug/Makefile qmake_all
            mingw32-make: Nothing to be done for 'qmake_all'.
            12:56:34: The process "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" exited normally.
            12:56:34: Starting: "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" -j4
            C:/Qt_new/Tools/mingw492_32/bin/mingw32-make -f Makefile.Debug
            mingw32-make[1]: Entering directory 'C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug'
            'C:\Qt_new\5.6.3\mingw49_32\bin\moc.exe' -DUNICODE -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug"' -DQT_QML_DEBUG -D__GNUC__ -DWIN32 -IC:/Qt_new/5.6.3/mingw49_32/mkspecs/win32-g++ -IC:/Users/Luis/Documents/AutoTest -IC:/Qt_new/5.6.3/mingw49_32/include -IC:/Qt_new/5.6.3/mingw49_32/include/QtTest -IC:/Qt_new/5.6.3/mingw49_32/include/QtCore -I. ../AutoTest/tst_myclass.cpp -o debug/tst_myclass.moc
            g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++0x -Wall -Wextra -frtti -fexceptions -mthreads -DUNICODE -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug"' -DQT_QML_DEBUG -I../AutoTest -I. -I../../../../Qt_new/5.6.3/mingw49_32/include -I../../../../Qt_new/5.6.3/mingw49_32/include/QtTest -I../../../../Qt_new/5.6.3/mingw49_32/include/QtCore -Idebug -I../../../../Qt_new/5.6.3/mingw49_32/mkspecs/win32-g++ -o debug/tst_myclass.o ../AutoTest/tst_myclass.cpp
            g++ -Wl,-subsystem,console -mthreads -o debug/AutoTest.exe debug/tst_myclass.o -LC:/Qt_new/5.6.3/mingw49_32/lib C:/Qt_new/5.6.3/mingw49_32/lib/libQt5Testd.a C:/Qt_new/5.6.3/mingw49_32/lib/libQt5Cored.a
            mingw32-make[1]: Leaving directory 'C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug'
            12:56:47: The process "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" exited normally.
            12:56:47: Elapsed time: 00:15.

            The project compiled and ran normally, even with the error

            aha_1980A 1 Reply Last reply
            0
            • G Gabriel_22

              Hello @Christian-Ehrlicher,

              Here is the compiler output:

              12:56:31: Running steps for project AutoTest...
              12:56:31: Starting: "C:\Qt_new\5.6.3\mingw49_32\bin\qmake.exe" C:\Users\Luis\Documents\AutoTest\AutoTest.pro -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
              12:56:33: The process "C:\Qt_new\5.6.3\mingw49_32\bin\qmake.exe" exited normally.
              12:56:33: Starting: "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" -f C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug/Makefile qmake_all
              mingw32-make: Nothing to be done for 'qmake_all'.
              12:56:34: The process "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" exited normally.
              12:56:34: Starting: "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" -j4
              C:/Qt_new/Tools/mingw492_32/bin/mingw32-make -f Makefile.Debug
              mingw32-make[1]: Entering directory 'C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug'
              'C:\Qt_new\5.6.3\mingw49_32\bin\moc.exe' -DUNICODE -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug"' -DQT_QML_DEBUG -D__GNUC__ -DWIN32 -IC:/Qt_new/5.6.3/mingw49_32/mkspecs/win32-g++ -IC:/Users/Luis/Documents/AutoTest -IC:/Qt_new/5.6.3/mingw49_32/include -IC:/Qt_new/5.6.3/mingw49_32/include/QtTest -IC:/Qt_new/5.6.3/mingw49_32/include/QtCore -I. ../AutoTest/tst_myclass.cpp -o debug/tst_myclass.moc
              g++ -c -pipe -fno-keep-inline-dllexport -g -std=gnu++0x -Wall -Wextra -frtti -fexceptions -mthreads -DUNICODE -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug"' -DQT_QML_DEBUG -I../AutoTest -I. -I../../../../Qt_new/5.6.3/mingw49_32/include -I../../../../Qt_new/5.6.3/mingw49_32/include/QtTest -I../../../../Qt_new/5.6.3/mingw49_32/include/QtCore -Idebug -I../../../../Qt_new/5.6.3/mingw49_32/mkspecs/win32-g++ -o debug/tst_myclass.o ../AutoTest/tst_myclass.cpp
              g++ -Wl,-subsystem,console -mthreads -o debug/AutoTest.exe debug/tst_myclass.o -LC:/Qt_new/5.6.3/mingw49_32/lib C:/Qt_new/5.6.3/mingw49_32/lib/libQt5Testd.a C:/Qt_new/5.6.3/mingw49_32/lib/libQt5Cored.a
              mingw32-make[1]: Leaving directory 'C:/Users/Luis/Documents/build-AutoTest-Desktop_Qt_5_6_3_MinGW_32bit3-Debug'
              12:56:47: The process "C:\Qt_new\Tools\mingw492_32\bin\mingw32-make.exe" exited normally.
              12:56:47: Elapsed time: 00:15.

              The project compiled and ran normally, even with the error

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Gabriel_22 said in QTEST_APPLESS_MAIN macro bug:

              The project compiled and ran normally, even with the error

              Than it sounds like a false positive from the Clang Code Model ... can you test a newer Qt version like 5.13.x if the problem still appears? Then you could file a bug report for that issue.

              Qt has to stay free or it will die.

              G 1 Reply Last reply
              3
              • aha_1980A aha_1980

                @Gabriel_22 said in QTEST_APPLESS_MAIN macro bug:

                The project compiled and ran normally, even with the error

                Than it sounds like a false positive from the Clang Code Model ... can you test a newer Qt version like 5.13.x if the problem still appears? Then you could file a bug report for that issue.

                G Offline
                G Offline
                Gabriel_22
                wrote on last edited by Gabriel_22
                #7

                I tried with Qt 5.13 and got the same error, but still compiling and running.
                I will file a bug report for this issue as suggested.
                EDIT:
                Link to report: https://bugreports.qt.io/browse/QTBUG-76790

                aha_1980A 1 Reply Last reply
                2
                • G Gabriel_22

                  I tried with Qt 5.13 and got the same error, but still compiling and running.
                  I will file a bug report for this issue as suggested.
                  EDIT:
                  Link to report: https://bugreports.qt.io/browse/QTBUG-76790

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Gabriel_22 Please add a link to the report here, so others can follow. Thanks!

                  Qt has to stay free or it will die.

                  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