在Eclipse Juno / Kepler / Luna CDT中启用C ++ 11 [英] Enabling C++11 in Eclipse Juno/Kepler/Luna CDT

查看:176
本文介绍了在Eclipse Juno / Kepler / Luna CDT中启用C ++ 11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:事实证明,这不是Eclipse Kepler的具体内容。我不得不使用相同的过程为Eclipse Juno。问题是在其他帖子中似乎缺少回答同样问题的步骤。

It turns out this really isn't specific to Eclipse Kepler. I had to use the same process for Eclipse Juno. The problem was that there seem to be missing steps in other posts answering this same question.

我正在使用Eclipse Kepler进行C ++,我试图使用C + +11并得到错误。当我编译时,我得到错误

I'm using Eclipse Kepler for C++ and I'm trying to use C++11 and getting errors. When I compile I get the error

错误:基于范围的循环不允许在C ++ 98模式下

error: range-based-for loops are not allowed in C++98 mode

我遵循了帖子中的说明

Eclipse CDT C ++ 11 / C ++ 0x支持

,为Eclipse Juno提供的解决方案不起作用。

and the solution given for Eclipse Juno isn't working.

不同的评论建议您重新启动日食,清理和重建。这没有什么不同。

Different comments have suggested restarting eclipse and cleaning and rebuilding. That hasn't made a difference.

推荐答案

有两件事你要做,首先你需要设置你的编译器,然后您需要设置CDT的语言处理器。既然你没有提到使用哪个编译器,我会认为它是GCC,但其他编译器的步骤将是类似的。 (请注意,当然需要一个支持C ++ 11的编译器。)

There's two things you have to do, first you need to setup your compiler, then you need to setup CDT's language processor. Since you didn't mention which compiler you're using, I'll assume it's GCC but the steps will be similar for other compilers. (Note that you need a compiler that supports C++11, of course.)

设置编译器是相当简单的:

Setting up the compiler is fairly straightforward:


  1. 右键单击项目,然后单击属性

  2. 在C / C ++ Build下单击设置

  3. 下GCC C ++编译器,单击其他

  4. 在其他标志框中,将-std = c ++ 11附加到令牌列表。

  5. 单击应用并确定

  1. Right click your project and click Properties
  2. Under C/C++ Build click Settings
  3. Under GCC C++ Compiler, click Miscellaneous
  4. In the Other Flags box, append "-std=c++11" to the list of tokens.
  5. Click Apply and OK

此时,您应该可以重建项目并使其运行。但CDT仍然可能会显示C ++ 11的错误。以下是您可以解决的问题:

At this point you should be able to rebuild your project and get it to run. But CDT still may show errors for C++11 includes. Here's how you can resolve that:


  1. 右键单击项目,然后单击属性

  2. 在C / C ++一般单击预处理器包含路径,宏

  3. 选择提供程序选项卡

  4. 列表中应该有一个类似GCC内置编译器设置。选择此条目。

  5. 取消选中使用全球提供商...选项

  6. 在列表下方有一个框,表示命令获取编译器眼镜。在这里附加-std = c ++ 0x。

  7. 使用右侧的上移按钮移动列表顶部的GCC内置编译器设置提供程序

  8. 单击应用,然后单击确定。

  9. 返回到Eclipse工作区,选择项目菜单,C / C ++索引,然后单击解决未解决的包括。

  1. Right click your project and click Properties
  2. Under C/C++ General click "Preprocessor Include Paths, Macros"
  3. Select the Providers tab
  4. There should be an item in the list that says something like "GCC Built in Compiler Settings". Select this entry.
  5. Uncheck the "Use global provider..." option
  6. Under the list there's an box that says "Command to get compiler specs." Append "-std=c++0x" to this.
  7. Move the "GCC Built in Compiler Settings" provider at the top of the list using the 'Move Up' button on the right.
  8. Click Apply and then OK.
  9. Back in your Eclipse workspace, select the Project Menu, C/C++ Index, and click "Re-resolve unresolved includes."

这篇关于在Eclipse Juno / Kepler / Luna CDT中启用C ++ 11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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