Eclipse cdt: Includes header file correct, compiles, but highlights source code: “Unresolved inclusion”

蓝咒 提交于 2021-02-18 11:52:41

问题


I have a project that uses a shared library from another project. In project settings I put the correct include paths and library for the GCC and G++ compiler (-L and -l option). It all compiles well, no problems here. But the source code is not analyzed correctly. My included headerfile (that is located in the other project) is marked as "Unresolved inclusion and everywhere I use something from it, the source is highlighted as well.

#include "myHeader.h"

Any ideas? thanks!


回答1:


The one that you are missing here (probably) is, telling the indexer where to look for those headers. I normally manage my own Makefile, so I do not know how to make it work for both the eclipse managed makefile and for the Indexer. Probably you will find that the solution below will fix both.

On the solution; right click on the project in the Project explorer ( or resource explorer ), and select Properties. Now under "C/C++ General" > "Paths and Symbols", click on Includes tab and select "GNU C++". Then on the right side, you can add various include paths ( similar to the -I option on gcc/g++ ) by clicking on "Add..." button.

Once you apply and click OK, the indexer will take a while to clear those unresolved object.




回答2:


A header should be included like this

#include "myHeader.h"

or if it's a standard lib header:

#include <string>

everything else is invalid.




回答3:


Remember to enable the Providers in the "Preprocessor Include Paths, Macros, etc.".



来源:https://stackoverflow.com/questions/12455508/eclipse-cdt-includes-header-file-correct-compiles-but-highlights-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!