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. [Solved] -std=c++0x causes compilation error
Forum Updated to NodeBB v4.3 + New Features

[Solved] -std=c++0x causes compilation error

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 7.9k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    lgeyer
    wrote on last edited by
    #1

    I am currently working on a project which should make use of some C++0x features. For this purpose I've added
    @
    QMAKE_CXXFLAGS += -std=c++0x
    @
    to the project file which - occasionally - leads to the following compiler error
    @
    g++ -c -std=c++0x -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include\QtCore" -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include\QtNetwork" -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include\QtGui" -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include\QtSql" -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include" -I"....\qx\include" -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\include\ActiveQt" -I"debug" -I"....\project\src" -I"." -I"c:\Development\qt\Desktop\Qt\4.7.3\mingw\mkspecs\win32-g++" -o debug\main.o ....\project\src\main.cpp
    In file included from c:\development\qt\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/bits/postypes.h:42,
    from c:\development\qt\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/bits/char_traits.h:42,
    from c:\development\qt\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/string:42,
    from c:\Development\qt\Desktop\Qt\4.7.3\mingw\include/QtCore/qstring.h:60,
    from c:\Development\qt\Desktop\Qt\4.7.3\mingw\include/QtCore/qobject.h:48,
    from c:\Development\qt\Desktop\Qt\4.7.3\mingw\include/QtCore/qtimer.h:48,
    from c:\Development\qt\Desktop\Qt\4.7.3\mingw\include/QtCore/QTimer:1,
    from ....\project\src\main.cpp:1:
    c:\development\qt\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:159: error: '::swprintf' has not been declared
    c:\development\qt\mingw\bin../lib/gcc/mingw32/4.4.0/include/c++/cwchar:166: error: '::vswprintf' has not been declared
    @

    The strange thing is, that commenting out the QMAKE_CXXFLAGS, compiling the project, commenting back in the QMAKE_CXXFLAGS and compiling the project again solves the problem - at least for a while. After doing a few changes to the source files the problem rises again.

    Is anyone else already creating C++0x projects and has experienced the same problem?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      Looks like it's a bug in MinGW (see also "here":http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40278). You can try to use -std=gnu++0x instead.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        Works like a charm so far - even though I've just realised that 4.4's support of C++0x is... moderate. Thanks!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Smar
          wrote on last edited by
          #4

          Newest MinGW available is 4.5.2, you might want to try it. That requires you to compile your own Qt, but Qt benefits from c++0x compilation too, according this: http://labs.qt.nokia.com/2011/05/26/cpp0x-in-qt/

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #5

            I will, thanks.

            JFYI "this":http://gcc.gnu.org/projects/cxx0x.html is a list of C++0x language features supported by the various versions of GCC / MinGW.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved