Scanner Discovery

General

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.

The Stand-alone Debugger will try to discover include paths and preprocessor symbols automatically. There are 2 main ways to discover those:

  1. Built-in Settings. The debugger will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output of this special run. Most compilers provide such an option to print built-in include paths and symbols. Built-in settings are implied and do not get passed to the compiler during regular compilation.
  2. Build Output Parser (BOP). Another method that the debugger employs is to analyze build output you provide to its Build Output Parser. Often, include paths are supplied to the compiler with -I options, and macros with -D options and BOP will try to find those in the output. That method relies on verbose build output of your build where all these options are actually printed by make. To specify build output either use the -b command-line option or else specify the location of the build log when using the File > New Executable... dialog.

The debugger 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.

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.

Preprocessor Include Paths and Macros Entries

If information retrieved by auto-discovery is insufficient a user can enter additional include paths and macros manually under "User Settings Entries".

Console View

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".

Spec Detectors Properties

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.

Console View

Related concepts
C/C++ Indexer

Related tasks
Setting up include paths and macros for C/C++ indexer

Related reference
C/C++ Preferences: Scanner Discovery
C/C++ Project properties: Preprocessor Include Paths, Macros, etc.