Elevenator

In Eclipse CDT it is inconvenient to configure the C++ version correctly for different projects. Multiple settings have to be adapted:

1. Compiler dialect settings
2. Discovery options
3. Optional: Configure Codan Checkers

The settings above need to be adapted to every new project in the worst case. Subsequently, creating new projects is a hassle of post-creation configuration. Elevenator makes this task significantly easier by allowing to configure the different C++ standard versions and the default setting to be used for new projects on workspace level.

Below we describe the possible options to be preconfigured for a new C++ project for a different C++ standard and how Elevantor sets up your projects.

Features of Elevenator

Applying all the settings for a different C++ version is repetitive work and the options are quite well hidden (see Behind the scenes). The Elevenator plug-in alleviates this and simplifies the configuration to a once and for all configuration for all new projects in a workspace. It allows to configure each C++ language standard version in one workspace and to select the desired version upon project creation in an additional wizard page.

Workspace Preferences

Elevenator allows to preconfigure the following versions of the C++ standard:

  • C++98
  • C++03
  • C++11
  • C++14 (1y)
  • C++17 (1z)
For each of the language versions above the following settings can be preconfigured:
  • Setting the compiler flag
  • Setting the discovery options
  • Enabling Elevator checkers
  • Enabling CharWars

Furthermore, the default version of C++ that should be chosen for a new C++ project can be configured in Preferences > C/C++ > Version:

New Project Wizard Page

With Elevenator, a new wizard page when creating a new C++ project and clicking two times Next> is available. It does not require input for the project to be created, but it allows to refine the settings for the new project (if desired). The settings are the same as seen in the workspace version settings.

Behind the Scenes

In this section we describe what configuration would be required to be performed manually for C++ projects without Elevenator.

Setting Compiler Dialect

In order to configure the underlying compiler to use the desired version of C++, a project needs to be configured accordingly. Eclipse CDT provides the possibility to configure this on project level for compilers supporting GCC options, like g++ and Clang. For example to configure g++ to use C++14, it needs the compiler flag -std=c++14

This project setting is hidden in the project properties: Project > Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Dialect > Language standard.

There are several possible standard versions predefined. Non-predefined flags can also be set in the Other dialect flags field. Unfortunately, there is no possibility in Eclipse CDT to configure this dialect option workspace-wide or at least for all projects relying on the selected toolchain. Eventually, all new projects have to be configured by hand.

Selecting a C++ standard version in this way only configures the compiler to use it when compiling the translation units of the project. It does not configure the internal analysis. To handle this correctly the following has to be done.

Setting Discovery Options

Eclipse CDT and the integrated code analysis framework analyze the source code of C++ projects, resolve symbols for navigation and do correctness checks (even for names declared externally). Such analysis is based on the index, which relies on the discovery options to be configured accordingly. Here we have the possibility to configure the discovery options on workspace or on project scope. While the compilation only depends on the compiler flags to be configured correcty, Eclipse CDT might display code analysis problems or cannot resolve declarations of symbols correctly that are only available in newer standard versions.

On Workspace Level

Discovery options for workspace scope can be configured in the workspace preferences: Preferences > C/C++ > Build > Settings > Discovery. Here the corresponding language settings provider can be configured with the same compiler flag used for the compiler.

The workspace scope settings are applied to all projects that are not specifically configured with distinct settings.

On Project Scope

Discovery options can also be set on project scope: Project > Properties > C/C++ General > Preprocessor Include Paths, Macros etc. > Providers. Here the corresponding language settings provider can be configured with project specific flags for the discovery process.

Configuring Codan Checkers

While compiler flags are mandatory for correct compilation and correctly set discovery options are very desirable, it might also be convenient to have further settings adapted to the C++ standard version. For example, the code analysis framework can have checkers available that analyze the source code targeting a specific C++ version. The Elevator plug-in for instance checks for correct initialization according to C++11 uniform initialization, which is undesirable in a C++03 project, because the proposed code is not valid.

Such codan checkers can be enabled and disabled on workspace and project level:
  • Workspace: Preferences > C/C++ > Code Analysis

  • Project: Project > Properties > C/C++ General > Code Analysis

Known Problems

Elevenator can only configure the project according to the settings provided upon project creation. When the toolchain is changed afterwards, the settings applied by Elevenator may get overwritten and are then lost. Thus we have explained the settings in detail in the introduction of this page.