CDT allows for comfortable environment with code highlighting, navigation, content assist and static analysis. However, most C/C++ projects have to be configured to enjoy those features. Most real life C/C++ projects heavily depend on code outside of the project itself, such as system headers or third party libraries. CDT indexer needs to process those to provide accurate index. Failure to set up these important settings assuredly will cause the assist tools misbehave.
CDT will try to discover include paths and preprocessor symbols automatically for supported tool chains. This process is known as Scanner Discovery or Autodiscovery. This discovery of symbols is twofold. One way, CDT will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output. Another method that CDT employs is to analyze build output of the regular build with Build Output Parser. Often, include paths are supplied to the compiler with -I options, and macros with -D options. That relies on verbose build output of your build where all these options are actually printed by make.
Scanner Discovery uses Language Settings Providers to find include paths and preprocessor symbols. Language Settings Providers can be configured on project properties page "Preprocessor Include Paths, Macros, etc.", Providers tab for a configuration and on preference page C/C++ Preferences: Scanner Discovery for shared providers.
If information retrieved by auto-discovery is insufficient or the project deviates from a standard one supported by CDT a user can inspect discovered entries and enter additional include paths and macros manually on the property page "Preprocessor Include Paths, Macros, etc.", Entries tab.
There are other ways to make C/C++ indexer aware of include paths or macros. One way is to set up them in MBS via "Paths and Symbols" project properties. See Including paths and symbols in Managed Build System. These entries are supplied to the indexer with MBS Language Settings Provider.
Scanner Discovery (sometimes called Autodiscovery) is a method of finding include paths and predefined preprocessor macros which the compiler uses during compilation of the code.
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 tool chains. 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.
Include paths and preprocessor macros for C/C++ indexer and other Language Settings are supplied by Language Settings Providers using Scanner Discovery mechanism.
The entries can be inspected and set up on project properties page "Preprocessor Include Paths, Macros, etc." - Entries tab.
Language Settings Providers can be set up and configured for the selected configuration on project properties page "Preprocessor Include Paths, Macros, etc." - Providers tab.
Include overridden.
Include paths and preprocessor macros for C/C++ indexer and other Language Settings are supplied by Language Settings Providers as part of Scanner Discovery. Language Settings Providers can be set up and configured for the selected configuration in the "Providers" tab.
"Providers" tab is only shown in properties of a project, not in properties of a file or a folder.
A user can define some options for configuration providers (or "non-shared") on this property page. Note that providers can be either shared or defined per configuration. Options of global (or "shared") providers can be configured on C/C++ Preferences: Scanner Discovery.
There are 2 specific options that are added for non-shared providers defined per configuration. They are described in the table below.
The rest of the options is described in C/C++ Preferences: Scanner Discovery, under Language Settings Providers Options.
Use.
The material provided in this article is also available with Eclipse Kepler C/C++ Development User Guide in Scanner Discovery section.
Back to the top