Eclipse 3.7.0 Indigo with CDT shows many false compilation errors

前端 未结 8 1630
予麋鹿
予麋鹿 2020-12-14 18:27

I have updated my Ubuntu box to 11.10 and then Eclipse also have been updated to 3.7.0 Indigo with CDT 8.0.1

Then the following problem occurs:

相关标签:
8条回答
  • 2020-12-14 19:04

    When you create a C++ project (in my case from existing code) you have to set the 'Toolchain for Indexer Settings' to the compiler you use ('GNU Autotools Toolchains' in my case). After this 'Path and Symbols' will show the correct path to the include files of your compiler. The bugs will disappear. This setting was useful only during creating the project, setting it later did not help.

    In indigo 3.7.2 version (and up may be) your changes can be effect after reindexing. Eclipse ask for "reindexing". Lower versions can require a manual reindexing header tags etc.

    0 讨论(0)
  • 2020-12-14 19:04

    I am answering here because this is the closest question to my problem.

    I used QT Eclipse integration with Helios (3.6.2) with no major problems. I was using mingw 4.6.2, which I had installed to c:\mingw. I wanted to upgrade to Indigo, which fixed some minor issues I was having with CDT.

    However, under Indigo (3.7 SR2) Eclipse began underlining trivial functions, as being unresolved, such as:

    function 'fprintf' could not be resolved
    function 'memset' could not be resolved
    

    even though #include was not underlined, could be opened, and included fprintf in the header. And even though the code itself compiled fine.

    If I went back to Helios, the problems went away.

    I tried reindexing, to no avail. I checked my include paths, and they were:

    c:\mingw\include
    C:\MinGW\lib\gcc\mingw32\4.6.2\include
    

    At first, I had just included the first, but not the second. But then I searched for "unresolved includes", and stdio.h was including stdarg.h, which wasn't in the main include folder of mingw, so I added the second. But still, printf was not resolved, and there were no more "unresolved includes".

    I created a new C++ project with one class. I added stdio.h, the paths above, and a call to fprintf. It was underlined! Even though other things from stdio were not underlined.

    Now I knew that it wasn't just a Qt problem.

    I worked around on this for a while before I read the bottom post here suggesting removing the include paths and compiling. I didn't believe it would work but gave it a shot. Amazingly, even though the compile failed, the error went away!

    It was then that I took another look at the include paths. They had been updated by the compile step to the following:

    c:/mingw/lib/gcc/mingw32/4.6.2/include-fixed
    c:/mingw/include
    c:/mingw/lib/gcc/mingw32/4.6.2/include
    c:/mingw/lib/gcc/mingw32/4.6.2/include/c++/backward
    c:/mingw/lib/gcc/mingw32/4.6.2/include/c++/mingw32
    c:/mingw/lib/gcc/mingw32/4.6.2/include/c++
    

    These were marked as "built-in" values which I assume means they weren't added by me and could get updated the next time I run a build.

    So, I guess the lesson is, including every single include path under mingw, even if Eclipse doesn't find it to be an unresolved include.

    The next step was to put all these paths into my Qt project. Unfortunately, after doing so, the unresolved functions were still there. It appears to be some sort of bug with the Qt C/C++ include paths which are different from the CDT C/C++ include paths.

    0 讨论(0)
提交回复
热议问题