Even a simplest C/C++ program just printing "Hello World" needs to include system headers. Consider:
#include <stdio.h> #include <stdlib.h> int main(void) { puts("!!!Hello World!!!"); return EXIT_SUCCESS; }
Indexer needs to be able to find headers stdio.h and stdlib.h and parse them to provide accurate index. In this example, the headers define prototype of function puts and macro EXIT_SUCCESS.
CDT will try to discover include paths and preprocessor symbols automatically for supported toolchains. There are 2 main ways to discover those:
CDT uses Language Settings Providers to discover the settings (starting with version CDT 8.1). Typically Language settings Providers are specialized. One will provide built-in compiler settings and another one settings detected by Build output Parser. There is also an extension point defined in CDT to allow third party Eclipse plugins to contribute custom Language Settings Providers.
The setting entries found by Scanner Discovery can be inspected in project properties on "Preprocessor Include Paths, Macros etc." page. Each Language Settings Provider can be expanded to show the entries it discovered.
If information retrieved by auto-discovery is insufficient or the project deviates from a standard one supported by CDT a user can enter additional include paths and macros manually under "User Settings Entries".
The Project Explorer View provides a means to view some of the settings. The discovered include paths are shown under the project when "Includes" node is expanded.
Also, a "Wrench" overlay icon is shown for those file/folders where distinct entries are discovered which differ from those of parent folder. Wrench is not shown on project level.
In the example below, Hello.cpp was compiled with added -DHELLO compiler option.
After BOP discovery "Wrench" overlay is shown for this file.
The output of built-in compiler specs detectors can be inspected to troubleshoot problems running the command. To do so, enable checkbox "Allocate console in the Console View".
When checkbox "Allocate console in the Console View" is enabled, output of each run of the provider will be directed to a special console in the Console View.
Setting up include paths and macros for C/C++ indexer
C/C++ Preferences: Scanner Discovery
C/C++ Project properties: Preprocessor Include Paths, Macros, etc.