Cannot install Eclipse Juno C ++ using std = C ++ 11

I have Eclipse Juno C ++ (Build id: 20120614-1722). I am trying to set the arguments to the compiler with the instruction -std = C ++ 11 or -std = C ++ 0x, but when compiling the code below. In Eclipse Juno (at least for Mac) there are no "tool settings", so I can not go to "C / C ++ Build β†’ Settings β†’ Settings". My compiler is GCC 4.8.0

#include <iostream> #include <sstream> #include <vector> using namespace std; int main(void) { vector<string> v = {"a","b","c"}; for(string s: v){ cout << s << endl; } return 0; } 

I got:

 HelloWorld.cpp:16:33: error: could not convert β€šΓ„Γ²{"a", "b", "c"}β€šΓ„Γ΄ from β€šΓ„Γ²<brace-enclosed initializer list>β€šΓ„Γ΄ to β€šΓ„Γ²std::vector<std::basic_string<char> >β€šΓ„Γ΄ HelloWorld.cpp:17:16: error: range-based β€šΓ„Γ²forβ€šΓ„Γ΄ loops are not allowed in C++98 mode 
+6
source share
3 answers

you can follow the steps described in this answer: Eclipse CDT support C ++ 11 / C ++ 0x

One possibility is that your options were applied to the wrong part of the tool chain.

+5
source

I ran into the same problem. Check if your project has a "makefile" ( *.mk ) user interface. If he has this "makefile", please put the following in your "makefile" and compile.

"LOCAL_CFLAGS: = -fexceptions -std = C ++ 0x -std = C ++ 11"

PS: LOCAL_CFLAGS is for compiler flags that you can put in "xxx> Miscellaneous". And, to be honest, I don’t know how to solve it if your project doesn’t have a custom "makefile". But Eclipse Juno literally has no way to the guys from the above.

0
source

The reason you don’t see the tool settings is because when you create the project you should select Executable instead of GNU Autotools

-1
source

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


All Articles