Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot set Eclipse Juno C++ with std=c++11

I have Eclipse Juno C++ ( Build id: 20120614-1722 ). I'm trying to set the compiler invocation arguments with instruction -std=c++11 or -std=c++0x but while compiling the code below. There is no "Tool Settings" in Eclipse Juno (at least for Mac), so I cannot go to "C/C++ Build -> Settings -> Tool 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
like image 245
Roman Kagan Avatar asked Jul 10 '12 19:07

Roman Kagan


1 Answers

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

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

like image 188
Carsten Greiner Avatar answered Sep 19 '22 12:09

Carsten Greiner