c ++ 11代码在Eclipse中生成语义错误,无法更改构建设置 [英] c++11 code generates semantic errors in Eclipse, can't change build settings
问题描述
我浏览过其他描述类似问题和可能修复的帖子,例如:
- 禁用Eclipse的错误发现。 (Codan假阳性)
- Eclipse编译成功但仍然会产生语义错误
- c ++ 0x编译但eclipse编辑器错误即使使用-gnu ++ 0x发现
- Eclipse CDT C ++ 11 / C ++ 0x支持
某些解决方案通过禁用索引器或禁用特定的错误/警告来掩盖问题,但是这不是可取的,因为我想在发生错误时看到真实错误。 / p>
其他(可能更正确的)解决方案描述了如何通过适当的宏(例如,__GXX_EXPERIMENTAL_CXX0X__)和构建标志(例如,-std = c ++ 11)但这是我认为的主要问题:我可以不要在IDE中更改这些设置。在项目 - >属性 - > C / C ++常规 - >预处理器包括路径,宏等中,条目和提供商选项卡显示为灰色/禁用。同样,在项目 - >属性 - > C / C ++构建 - >设置中,其他一些帖子中没有提到工具设置或发现的选项卡。
一些细节:我在Ubuntu 13.10 x64上使用Kepler build 20140224-0627。我正在尝试使用的代码是Android NDK(最新版本,r9d),我安装了Google的NDK插件。编译器是gcc 4.8,并使用gnustl_static运行时库。也许使用NDK工具链/插件禁用我需要修改的设置?
任何帮助都非常感谢。
首先,确保您的项目正确编译。
之后,请转到 c / c ++构建 - > 工具链编辑器,然后选择当前工具链: Linux GCC (您可能需要关闭仅显示兼容的工具链)。确保当前构建器仍然是Android Builder 。
现在您可以完全访问 C / kbd> - > 路径和符号页面, h包含 和 #符号 标签页
在这两个选项卡上,我手动添加
/ 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 ++透视图,右键单击项目并启动索引 - > 重建。
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. (Codan 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.
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.
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?
Any help is greatly appreciated.
First, make sure that your project compiles correctly.
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.
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
and
__GXX_EXPERIMENTAL_CXX0X__ = 1
Maybe you need to switch to C/C++ Perspective, right-click on the project and launch Index->Rebuild.
这篇关于c ++ 11代码在Eclipse中生成语义错误,无法更改构建设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!