How to remove error “unresolved inclusion” for use

2019-09-04 21:48发布

问题:

i have imported existing IAR C++ Project for ARM into eclipse IDE , with plugin added for IAR tool chain. The project got imported , but some files are not getting included. It gives error :Unresolved inclusion" and text is underlined with red color. I have added path for these files as shown below but still same error is there . Please suggest for removing this error.

include "./../../../try_one/try_headers/limits.h"

回答1:

You need to configure Eclipse's indexer properly. If your project's type is "Makefile project" (so not any "managed" type, where you enter the compilation options/flags in Eclipse) you can do that as described below.

Go to your project's properties, then "C/C++ General" > "Preprocessor Include Paths, Macros etc." and switch to "Providers" tab. Uncheck everything other than:

  • CDT GCC Build Output Parser,
  • CDT Cross GCC Built-In Compiler Settings (depending on your project exact type, this should be some other type - for "Cross GCC" project, you select "... Cross GCC ..." checkbox).

Configure them as in below pictures:

In the first case you replace:

(gcc)|([gc]\+\+)|(clang)

with:

.*((gcc)|([gc]\+\+)|(clang))

This way Eclipse will know that all your lines starting with "... arm-none-eabi-gcc ..." or "... arm-none-eabi-g++ ..." are compiler invocations, so it will be able to parse the flags, including the include paths (-I flags). You can alter the options File/Folder/Project - depending on your configuration.

In the second case you replace what's in the textbox with something similar to:

arm-none-eabi-${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}" -std=gnu++11 -std=gnu99 -mcpu=cortex-m4 -mthumb

And you need to specify proper flags, depending on your project. You enter only the flags that matter for the "built-in compiler settings" - these are -std, -mcpu, -mthumb, -mfpu, etc. As you see, you should enter flags for both C and C++ (if you use C++).

Of course if your compiler prefix is not "arm-none-eabi-" you should modify the options accordingly.

After that you should do a full rebuild of your project, so that Eclipse would be able to see ALL compilation commands for ALL files from your project. If your makefile hides the actual commands (for example it displays only "CC: some_file.c" instead of full command that is actually executed) this feature has to be disabled (you can alter the way make is invoked in project's properties under "C/C++ Build" in "Behavior" tab in "Build (incremental build)" textbox).

Sometimes it is also necessary to rebuild index manually, so right-click your project and go to "Index" > "Rebuild" (sometimes other options help too). Close all editors, maybe even close the project, and after reopening it should be OK.

After all these steps you should see a small "wrench" icons on your sources (or folders or whole project - depending on what you selected in the parser) - after you click such element with right button, select Properties and "C/C++ General" > "Preprocessor Include Paths, Macros etc." you should be able to see what Eclipse discovered there: