Error: in C ++ 98 mode, "range" for range-based loops are not allowed

So, I follow the tutorials on this page: http://www.cplusplus.com/doc/tutorial/control/ But I am having problems with the range / based loop. I found this page: Updating the GNU GCC Compiler The response says that I have to open Project and Properties. But when I try to do this, the "Properties" option is not available without explanation: http://imageshack.com/a/img571/4371/xd1x.png So, how can I activate the / range for loops?

+4
source share
7 answers

pass -std=c++11 flag to the compiler. Of course, GCC should be fresh enough (> = 4.7) to support all of these modern standards. For CodeBlocks 13.12: Settings โ†’ Compiler โ†’ Tab โ€œCompiler Flagsโ€ โ†’ Option โ€œHave g ++, following C ++ 11 ISO C ++ [-std = C ++ 11]โ€

+16
source

The above solution using -std=c++11 does not work for me.

This is information about the purpose and version of my compiler.
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) Target: x86_64-linux-gnu

When I tried, this is what happened.
$ g++ -std=c++11 program.cpp cc1plus: error: unrecognized command line option '-std=c++11'

This solved the problem for me.
$ g++ -std=c++0x program.cpp

+6
source

Both of these:

 g++ -std=c++11 -o test_executable test_source.cpp g++ -std=c++0x -o program program.cpp 

worked for me.

The only thing that needs to be done after compilation is to execute test_executable (in the first case) as ./test_executables or a program (in the second case) as ./program .

+2
source

Using the above solution g++ -std=c++0x program.cpp works. However, the command must be slightly modified to run the program using the general command: ./program

I used g++ -std=c++0x -o program program.cpp and everything worked fine.

+1
source

If you are using QT5.5 , you can achieve this by adding the following lines to your .pro file.

CONFIG += c++11

0
source

Dev-Cpp 5.11 Simply put, you can click on Tool> Compiler Option> Settings> Code Generation> and select the language of the last option (ISO C ++ 11).

enter image description here

0
source

Please tell us how to get the necessary gcc to work with each cycle. I use code blocks

0
source

Source: https://habr.com/ru/post/975456/


All Articles