无法使用std = c ++ 11设置Eclipse Juno C ++ [英] Cannot set Eclipse Juno C++ with std=c++11

查看:310
本文介绍了无法使用std = c ++ 11设置Eclipse Juno C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Eclipse Juno C ++(版本号:20120614-1722)。我试图设置编译器调用参数与指令-std = c ++ 11或-std = c ++ 0x,但在编译下面的代码。在Eclipse Juno中没有工具设置(至少对于Mac),所以我不能去C / C ++ Build - >设置 - >工具设置。我的编译器是GCC 4.8.0

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;
}

我有:

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


推荐答案

你可以按照我在这个答案中描述的步骤:
Eclipse CDT C ++ 11 / C ++ 0x支持

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.

这篇关于无法使用std = c ++ 11设置Eclipse Juno C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆