Eclipse 3.7无法在C ++编辑器中解析Types [英] Eclipse 3.7 cannot resolve Types in C++ Editor

查看:411
本文介绍了Eclipse 3.7无法在C ++编辑器中解析Types的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从Eclipse 3.6更改为Eclipse 3.7,我在Ubuntu 11.04中用于C ++开发。



使用版本3.6,我没有大的麻烦,除了我总是有​​一些索引器的问题。
现在版本3.7它开始标记未解决的类型作为错误。因为索引器似乎更不喜欢我,我的Eclipse显然不知道类型 uint16_t size_t



与代码编辑器中显示的错误相反,我的编译器没有编译代码和解析所有符号和类型的问题,所以这似乎是一个问题, IDE本身。



有什么方法可以避免这种行为,因为所有的红色下划线使我的代码越来越不可读...?



更新:



好的一些研究和Dennis的回答我发现我需要添加一些路径
项目属性/ C / C ++常规/路径和符号



的I32目标,我不能只添加 / usr / include
而我需要添加



/ usr / powerpc-linux-gnu / libc / usr / include



(如 stdint.h )。
也需要:



/usr/lib/gcc/powerpc-linux-gnu/4.5.1/include stdarg.h



现在几乎所有的错误都消失了。唯一仍然困扰我的函数是 stdio.h 标题中的 printf 。我查找它,头文件本身位于包含的路径内。仍然我得到一个错误,说函数printf无法解决。我想再次注意,这些只是由Eclipse显示的错误 - 编译本身工作正常。



所以这实际上引发了3个问题:



  • 在项目属性中,路径和符号部分与包含路径的 C ++ Build / Settings / C ++包括节。这意味着在其中一个节中添加/删除路径会直接影响其他节的输入。由于 C ++ Includes 直接与编译器一起使用,我不知道为什么编译器可以编译correcty(并找到头),即使他们没有传递给他作为一个路径?


  • 为什么他找不到 printf 在eclipse?包含头文件 stdio.h ,它还包含 printf 的声明 - 为什么Eclipse代码编辑器告诉


  • 为什么头文件被分开这么多?我知道,如果我正在建设另一个traget(例如PowerPC),我需要其他头文件 - 但为什么GNU GCC分开不同的dirs中的头?



  • 解决方案

    常见类型的红色下划线通常是由于您的包含路径中的标准库。看看你的项目的包含...它们在项目属性中。确保您的C ++包含的条目与您使用的编译器的C ++标准libs文件夹匹配。


    I recently changed from Eclipse 3.6 to Eclipse 3.7 , which I am using for C++ development in Ubuntu 11.04 .

    With Version 3.6 I had no big troubles, except that I always had some issues with the indexer. Now with Version 3.7 it begins marking unresolved Types as Errors. Since the indexer seems to dislike me even more, my Eclipse apparently doesn't know types like uint16_t or size_t.

    In contrary to the displayed errors in the code editor, my compiler has no problems with compiling the code and resolving all symbols and types, so this seems to be a problem of the IDE itself.

    Are there any ways to avoid this behavior, because all the red underlines make my code more and more unreadable...?

    Update:

    Okay with some research and the answer from Dennis I found out that I need to add some paths to Project Properties/ C/C++ General/ Paths and Symbols

    Since I am building for a PowerPC instead of a I32 target, I can not just add /usr/include . Instead I needed to add

    /usr/powerpc-linux-gnu/libc/usr/include

    for all the standard headers (like stdint.h). Also I needed:

    /usr/lib/gcc/powerpc-linux-gnu/4.5.1/include

    for the stdarg.h.

    Now almost all the errors are gone. The only function which still troubles me is printf from the header stdio.h. I looked it up and the header file itself lies within the included paths. Still I get an Error which says Function printf could not be resolved. I want to note again, that these are just errors displayed by Eclipse - The compiling itself works fine.

    So this actually throws up 3 questions:

    1. In the project properties the Paths and Symbols section coheres with the include Paths out of the C++ Build/Settings/C++ Includes section. This means adding/deleting a path in one of those sections directly affects the entry of the others. Since the C++ Includes directly coheres with the Compiler I wonder why the compiler can compile correcty ( and finds the headers ) even if they arent passed to him as a path? Is there some kind of standard path GCC uses, which I don't know about?

    2. Why doesn't he find printf in eclipse? The headerfile stdio.h is included and it also contains the declaration of printf - so why does the Eclipse Code Editor tell me that it can't resolve it?

    3. Why are the header files divided so much? I am aware that I need other header files if I am building for another traget (e.g. PowerPC) - But why does the GNU GCC separate those headers in different dirs?

    解决方案

    The red underlines for common types are usually caused by not having your standard library in your include path. Look at your includes for your project... they are in the project properties. Ensure that your C++ includes have an entry that matches the C++ standard libs folders for the compiler you are using.

    这篇关于Eclipse 3.7无法在C ++编辑器中解析Types的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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