C++11 range-based for loop doesn't seem to be working?
-
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?
-
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?
-
Has this been resolved? I could not get it to compile either (gcc 4.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]
-
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.
-
Aha! That explains it. Thanks :-)