Search code examples
ceclipseeclipse-cdt

Make Eclipse CDT pre-include a header file, to avoid error: "Symbol <symbol> could not be resolved"


Is there a way to make the Eclipse editor presume that a specific C header file has already been included, without having to #include it explicitly?

For example, how can we achieve:

#include "common_type_defs.h"
#include "special_type_defs.h" // Don't want to have to mention this header file

main()
{
  common_type var1;
  special_type var2;
  .....
}

by writing only:

#include "common_type_def.h"

main()
{
  common_type var1;
  special_type var2; // Eclipse editor: "Symbol 'special_type' could not be resolved"
  .....
}

without getting the Eclipse editor annotation error: "Symbol 'special_type' could not be resolved".

The reason is, the project uses a custom scripted build system. The special header files are added automatically by the build system, selected from different libraries. So the build succeeds.

I have added the special header folder to the include paths of the project. This allows me to hit [F3] and jump to the definition of "special_type". It is just that the editor flags an error.

I do not want to silence the error because I want to catch real errors.

Any suggestions?


Solution

  • Go to:
    Project propertiesC/C++ GeneralPreprocessor Include Paths, Macros etc.EntriesGNU C
    Select CDT User Setting Entries and than click Add button. Select Include File and enter your preprocessor pre-include file here.

    Apply and rebuild indexer.

    My pre-included ppdefs.h file

    I am using Oxygen.1a Release (4.7.1a)