Important: Please read the Qt Code of Conduct -


  • 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
        MyClass ();
        ~MyClass ();
    private slots:
        void test_case1();
    MyClass::MyClass ()
    MyClass::~MyClass ()
    void MyClass::test_case1()
    #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

  • Lifetime Qt Champion

    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?


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

  • Lifetime Qt Champion

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

  • 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\ -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

  • Lifetime Qt Champion

    @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.

  • 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.
    Link to report:

  • Lifetime Qt Champion

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

Log in to reply