Qlist error on windows



  • Hi,

    I am trying to move a qt project from linux to windows. Although my application compiles and runs on linux, when compiling on windows I get a bunch of really ugly errors (below). I appreciate any ideas on how to solve or debug this problem.

    Thanks.

    Here are the errors:
    C:\QtSDK\QtCreator\bin\jom.exe -nologo -j 8 -f Makefile.Debug cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtOpenGL" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include" -I"C:\Users\ethan\Documents\Visual Studio 2010\Projects\IGLU" -I"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include" -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\ActiveQt" -I"debug" -I"." -I"..\BasicOGL" -I"." -I"c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspecs\win32-msvc2010" -Fodebug\ @C:\Users\ethan\AppData\Local\Temp\main.obj.4320.16.jom
    main.cpp
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(345) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(361) : see reference to class template instantiation 'QList<T>' being compiled
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(345) : error C2143: syntax error : missing ',' before '<'
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(347) : error C2143: syntax error : missing ';' before '<'
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(347) : error C2433: 'QList<T>::list' : 'inline' not permitted on data declarations
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(347) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(348) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qlist.h(345) : error C2039: 'list' : is not a member of 'std'
    c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore/qobject.h(93) : see reference to class template instantiation 'QList<T>' being compiled with
    [
    T=QObject *
    ]


  • Moderators

    How does the code look like?



  • The errors were caused by this chunk of code in qlist.h:
    @
    #ifndef QT_NO_STL
    static inline QList<T> fromStdList(const std::list<T> &list)
    { QList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
    inline std::list<T> toStdList() const
    { std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
    #endif
    @
    So I seem to have resolved the problem by defining QT_NO_STL in my .pro file. Since I do not use anything from the STL this is not an issue. However, its silly that the compilation of internal qt headers would be inconsistent between Windows / Linux. I'd appreciate further explanation of what exactly the above errors mean.



  • What about your code?



  • If I knew what code of my was causing this problem then I would have some idea of how to solve it.
    But I have no idea what is causing this error as the compiler errors refer only to qlist.h.

    Any suggestions on how to find which parts of my code cause the error?



  • From experience, if something goes wrong in a third-party header file you include, then it's quite often a mistake in your own code before the #include statement, maybe indirectly through another #include statement.

    You could try something very simple like:
    @//Test.cpp
    #include <QList>

    int myTest(void)
    {
    QList<int> test;
    test << 42;
    return test.size();
    }@

    If a file with only that content won't compile either, it would indicate that something with your build environment and/or your Qt configuration is wrong. If it does compile fine, then carefully check your other code again. In particular, I would try to strip down your code as much as possible, until it compiles through. Then re-add the code line-by-line until it fails to compile again, so you will find the "problematic" part...


  • Moderators

    When I get errors like this it is my code causing it in about 99.9% of all cases. So what does your code look like? It seems to be compiling main.cpp when triggering those errors.



  • How did you initialize your QList object? If you need help, provide some of your coude where the QList is used. Probably it's not a Qt issue but a C++ one.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.