C ++ 11 code在Eclipse中产生语义错误,无法更改构建设置 [英] c++11 code generates semantic errors in Eclipse, can't change build settings

查看:422
本文介绍了C ++ 11 code在Eclipse中产生语义错误,无法更改构建设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在用Eclipse CDT的C ++ 11 code麻烦。在code编译罚款,但在编辑器中我看到,以C ++ 11标准库中的所有引用(比如std :: shared_ptr的和std ::时辰::毫秒)被发现服务/索引标记为错误,其中prevents被运行程序。包含文件被发现,但我认为正确的标志和宏没有得到通过对CDT的内部检查繁殖,所以没有类型或头的主要内容进行定义。我也似乎无法在项目属性来更改相应的设置。

I'm having trouble with c++11 code in Eclipse CDT. The code compiles fine, but in the editor I see that all references to c++11 standard library (such as std::shared_ptr and std::chrono::milliseconds) are flagged as errors by the discovery service / indexer, which prevents the program from being run. The include files are found, but I think the proper flags and macros aren't getting propagated through to CDT's internal checks, so none of the types or main content of the headers are defined. I also can't seem to change the appropriate settings in the project properties.

我浏览描述类似的问题和可能的解决方法,如其他职位:

I've browsed other posts describing similar issues and possible fixes, such as:

  • Disable Eclipse's error discovery. (c++11 false positives)
  • Eclipse compiles successfully but still gives semantic errors
  • c++0x compiles but eclipse editor errors even with -gnu++0x discovery
  • Eclipse CDT C++11/C++0x support

一些解决方案通过禁用索引掩盖了问题,或者禁用特定错误/警告,但是这是不可取的,因为我确实想发生时看到真正的错误。

Some solutions mask the problem by disabling the indexer, or by disabling specific errors/warnings, but this is not desirable as I do want to see true errors when they occur.

其他(可能更正确)的解决方案描述了如何通过适当的宏通(如,. __GXX_EXPERIMENTAL_CXX0X__),并建立标志(如-std = C ++ 11),但这里是我认为是主要问题:我在IDE无法更改这些设置。在项目 - >属性 - > C / C ++常规 - > preprocessor包括路径,宏等的条目和供应商的标签显示为灰色/禁用。同样,在项目 - >属性 - > C / C ++编译 - >设置,也有工具设置或发现任何选项卡中的一些其他职位提到

Other (and probably more correct) solutions describe how to pass through appropriate macros (e.g,. __GXX_EXPERIMENTAL_CXX0X__) and build flags (e.g., -std=c++11), but here's what I think is the main issue: I can't change these settings in the IDE. In "Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros, etc", the Entries and Providers tabs are grayed out / disabled. Similarly, in "Project -> Properties -> C/C++ Build -> Settings", there are no tabs for Tool Settings or Discovery as mentioned in some of the other posts.

一些细节:我使用开普勒建立在Ubuntu 13.10 64 20140224-0627。在code我想一起工作是Android NDK(最新版本,r9d),我已经安装了谷歌的NDK插件。编译器是gcc 4.8,并使用gnustl_static运行时库。也许使用NDK工具链/插​​件禁用,我需要修改设置?

Some particulars: I'm using Kepler build 20140224-0627 on Ubuntu 13.10 x64. The code I'm trying to work with is for Android NDK (latest version, r9d), and I have Google's NDK plugin installed. Compiler is gcc 4.8, and using gnustl_static runtime library. Perhaps using the NDK toolchain/plugin disables the settings that I need to modify?

任何帮助是极大AP preciated。

Any help is greatly appreciated.

推荐答案

首先,请确保您的项目正确编译。

First, make sure that your project compiles correctly.

之后,转到<大骨节病> C / C ++编译 - > <大骨节病>工具链编辑器并选择<大骨节病>当前工具链:的Linux GCC (您可能需要关闭<大骨节病>显示兼容的工具链仅)。确保<大骨节病>当前建设者还是 Android的生成器

After that, go to C/C++ Build->Tool Chain Editor and choose Current toolchain: Linux GCC (you may need to switch off Display compatible toolchains only). Make sure that the Current builder is still Android Builder.

现在,你可以完全访问<大骨节病> C / C ++常规 - > <大骨节病>路径和符号页,其中<大骨节病> H包括 和<大骨节病> #符号 标签。

Now you have full access to C/C++ General->Paths and Symbols page, with h Includes and # Symbols tabs.

在这两个选项卡,我手动添加

On these two tabs, I add manually

C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/include
C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
C:/Android/android-ndk-r9d/sources/cxx-stl/gnu-libstdc++/4.6/include/backward

__GXX_EXPERIMENTAL_CXX0X__ = 1

也许你需要切换到的 C / C ++透视的,该项目右键单击并启动<大骨节病>首页 - > <大骨节病>重建

Maybe you need to switch to C/C++ Perspective, right-click on the project and launch Index->Rebuild.

这篇关于C ++ 11 code在Eclipse中产生语义错误,无法更改构建设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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