33

I am just learning how to write range based for loops, but the only problem is that my compiler, Orwell Dev-C++ doesn't seem to support it in its default mode (which is c++98). How can I change this mode to another one that supports this feature (and other features of C++0x). Thanks. Also:

This was the error message: [Error] range-based-for loops are not allowed in C++98 mode

I run Windows 8

The version I have of Dev C++ is 5.3.0.3

And the compiler is TDM-GCC 4.6.1 64 bit.

Thanks to everyone

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
Victor Odouard
  • 1,345
  • 3
  • 15
  • 28

7 Answers7

66

Go to Tools -> Compiler Options -> "Compiler" tab

Check the checkbox labeled, "Add the following commands when calling the compiler" And add in the text entry box, "-std=c++11" or if that doesn't work "-std=C++0x"

Should be something like that anyway, I haven't had Dev C++ installed for many years, so I had to look at some screenshots on Google to remember.

Jamin Grey
  • 10,151
  • 6
  • 39
  • 52
  • hmmm....doesn't seem to work. the error messave is: [Error] unrecognized option '-static-libgcc-std=c++0x' – Victor Odouard Jun 05 '13 at 23:55
  • oh...I was doing it wrong. It actually does work. Thanks so much. – Victor Odouard Jun 06 '13 at 00:12
  • 1
    @user2457666 If this answer worked for you, you should mark it as accepted (use the check mark to the left, just below the number of votes received). – Gorpik Jun 06 '13 at 10:54
  • Thanks @Jamin Grey, it worked for me. Here is the screenshot of how it should look like in the compiler option. https://i.postimg.cc/SR12Zm6P/Capture.png – Kavin Raju S Jan 13 '21 at 01:42
11
  1. Download from the following link http://orwelldevcpp.blogspot.in/2015/04/dev-c-511-released.html

  2. Go to Tools->Compiler Option->Programs

and add -std=c++11

see the image

enter image description here

Kapil Batham
  • 157
  • 1
  • 3
7

In Dev C++ 5.2.0.3 it's as simple as go to Tools->Compiler Options->Settings->Code Generation and setting Language standard (-std) to ISO C++11

Phil321
  • 201
  • 4
  • 5
6

By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to:enter image description here

Here, select the "Settings" tab, and within it, the "Code Generation" tab. There, in "Language standard (-std)" select "ISO C++ 11":

enter image description here

Ok that. You are now ready to compile C++11!

Purgoufr
  • 761
  • 14
  • 22
0

Was facing the same issue in Code::Blocks. to fix the problem, in Build Options->Compiler Flags, tick the box "Have g++ follow the c++11 ISO C++ language standard [-std=c++11]"

0

In Dev-C++ 5.11 an error comes in new tab like this:

This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

For this you have to follow four simple steps:

  1. Go to Tools Tab
  2. Select Compiler Options..
  3. Go to General tab
  4. Check the checkbox named "Add following commands when calling the compiler", write this statement -std=c++11, and then press OK

Conclusion: Error is removed

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40
0

Tested On: Dev-C++ 5.11


if you want to code with c instead of c++ and have this issue, do these steps:

  1. Tools > Compiler Options > Settings Tab > Code Generations
  2. set the "Language standard (-std)" to "ISO C99"

you still get the warning although it works for you now.

David SG
  • 1
  • 1