Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Range-based 'for' loops are not allowed in C++98 mode

So I'm following the tutorials on this page: http://www.cplusplus.com/doc/tutorial/control/ But I'm having trouble doing a range/based for loop. I found this page: GNU GCC compiler updatingThe answer there says I should open "Project" and "Properties". But when I try that, the "Properties" option is grayed out with no explanation: http://imageshack.com/a/img571/4371/xd1x.png So.. how can I activate range/based for loops?

like image 686
Sindre Avatar asked Apr 04 '14 09:04

Sindre


People also ask

How do I enable C++ 11 in Dev CPP?

To do this, click on Tools in Dev-C++ IDE. Under this click the “Settings” tab. Inside the settings tab, we can see the “Code generation” tab. Click on the “Language Standard (-std)” value and set it to “ISOC++11” or “GNUC++11” as per your requirement.


1 Answers

Pass -std=c++11 flag to the compiler. Certainly GCC should be fresh enough (>=4.7) to support all these modern standards. For CodeBlocks 13.12: Settings -> Compiler -> Tab "Compiler Flags" -> Option "Have g++ follow the C++11 ISO C++ [-std=c++11]"

like image 200
user3159253 Avatar answered Sep 27 '22 22:09

user3159253