Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. C++11 range-based for loop doesn't seem to be working?
Forum Updated to NodeBB v4.3 + New Features

C++11 range-based for loop doesn't seem to be working?

Scheduled Pinned Locked Moved C++ Gurus
6 Posts 4 Posters 4.6k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    In "this":http://labs.qt.nokia.com/2011/05/26/cpp0x-in-qt/ blog post it says:

    bq. you can write
    @for (const QString &option : optionList) { ... }@

    However Qt Creator complains about unexpected : and the code actually fails to compile, I've tested with the bundled gcc4.4 as well as with 4.6. I have put the c++11 enable flag in the .pro file...

    Any ideas?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris H
      wrote on last edited by
      #2

      It definitely won't work in gcc 4.4, it wasn't implemented yet in that version. But gcc 4.6 had it, so in theory that one should have been working, anyway. Can you manually compile the file with the @-std=gnu++0x@ option to make sure that works?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        miroslav
        wrote on last edited by
        #3

        Has this been resolved? I could not get it to compile either (gcc 4.4).

        Mirko Boehm | mirko@kde.org | KDE e.V.
        FSFE Fellow
        Qt Certified Specialist

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          [quote author="miroslav" date="1324289655"]Has this been resolved? I could not get it to compile either (gcc 4.4).[/quote]

          [quote author="Chris H" date="1324054693"]It definitely won't work in gcc 4.4, it wasn't implemented yet in that version.[/quote]

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

            C++11 support of GCC 4.4 is "mediocre":http://gcc.gnu.org/gcc-4.4/cxx0x_status.html - at best. For example there is no support for range-based for loops. You will have to update to a more recent version of GCC, like 4.6 or 4.7.

            In addition, you will need a recent version of Qt - 4.8 at least.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              miroslav
              wrote on last edited by
              #6

              Aha! That explains it. Thanks :-)

              Mirko Boehm | mirko@kde.org | KDE e.V.
              FSFE Fellow
              Qt Certified Specialist

              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