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

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

问题描述

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

  #include< iostream> 
#include< sstream>
#include< vector>
使用命名空间std;
int main(void){
vector< string> v = {a,b,c}; (string s:v)的
{
cout<< s < ENDL;
}
return 0;
}

我有:

  HelloWorld.cpp:16:33:错误:无法转换,Äò{a,b,c},Äô从,Äò& ;Äôto,Äòstd:: vector< std :: basic_string< char> >,Äô
HelloWorld.cpp:17:16:错误:基于范围的,C ++ 98模式中不允许使用Äòfor,Äô循环


解决方案

您可能会按照我在此答案中描述的步骤:
Eclipse CDT C ++ 11 / C ++ 0x支持



一种可能性是您的选项被应用到工具链的错误部分。


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

解决方案

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 ++设置Eclipse Juno C ++ 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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