Search code examples
c++eclipsegccideeclipse-cdt

Add header to every file in project setting (gcc -include)


I have a project which use gcc -include file.h

As gcc documentation say, this ensures that file.h is included in every file which is compiled this way (meaning like there was #include "file.h" in every other files).

Now I have imported this project into eclipse and I set up the include path where that file is but can't figure out how to do something like gcc -include in eclipse project setting. The result of this is that in editor I have a LOT of "Symbol xy could not be resolved" but the project compiles just fine.

Thanks for any help.


Solution

  • You can change the CDT GCC Built-in Compiler Settings on a project-by-project basis.

    • Go to Project -> Properties -> C/C++ General -> Preprocessor Include Paths, Macros etc.
    • Select the Providers tab.
    • Select CDT GCC Built-in Compiler Settings
    • Unselect Use global provider shared between projects
    • Add the required GCC flags to the Command to get compiler specs: input box

    (see highlighted text in image below)

    enter image description here

    You probably want to click Store entries in project settings folder