Skip to content

Predefined Macros

guwirth edited this page Jan 22, 2021 · 11 revisions

The cxx plugin already defines some macros to be functional. For most build environments, these predefined macros are not sufficient. Please check your build environment and project settings to see which additional macros you need to define with sonar.cxx.defines.

Some links to common build environments and their Predefined Macros.

Predefined macros of the cxx plugin:

| Macro | Value | Comment | |--- | --- | --- | --- | | __FILE__ | "file" | always the same dummy value | | __LINE__ | 1 | always the same dummy value | | __DATE__ | "??? ?? ????" | indicates 'date unknown' | | __TIME__ | "??:??:??" | indicates 'time unknown' | | __STDC__ | 1 | 1 means that this compiler conforms to ISO Standard C | | __STDC_HOSTED__ | 1 | This macro is defined, with value 1, if the compiler’s target is a hosted environment. A hosted environment has the complete facilities of the standard C library available. | | __cplusplus | 201103L | language standard C++11 |

Automatically extract macros from the build system

The cxx plugin can also automatically extract macros from MSBuild .LOG files or JSON Compilation Databases. More information can be found at the respective parameter sonar.cxx.msbuild.reportPaths or sonar.cxx.jsonCompilationDatabase.

Clone this wiki locally