-cpp-version)Specify C++ language standard followed in source code
Specify the C++ language standard that you follow in your source code.
User interface (desktop products only): In your project configuration, the option is on the Target & Compiler node. See Dependencies for other options that you must enable.
Command line and options file: Use the option
-cpp-version. See Command-Line Information.
Use this option so that Polyspace® can allow features from a specific version of the C++ language
standard during compilation. For instance, if you compile with GCC using the flag
-std=c++11 or -std=gnu++11, specify
cpp11 for this option. If you are not sure of the
language standard, specify defined-by-compiler.
For instance, suppose you use range-based for loops. This type
of for loop is defined in the C++11 standard but unrecognized in
prior standards such as C++03. If the Polyspace compilation uses the C++03 standard, you can see compilation
errors.
To check if your compiler allows features specific to a standard, compile code
with macros specific to the standard using compiler settings that you typically use.
For instance, to check for C++11-specific features, compile this code. The code
contains a C++11-specific keyword nullptr. If the macro
__cplusplus is not 201103L (indicating
C++11), this keyword is used and causes a compilation
error.
#if defined(__cplusplus) && __cplusplus >= 201103L
/* C++11 compiler */
#else
void* ptr = nullptr;
#endif
cpp11 for this option.Default:
defined-by-compiler
defined-by-compilerThe analysis uses a standard based on your specification for Compiler (-compiler).
See C/C++ Language Standard Used in Polyspace Analysis (Polyspace Bug Finder).
cpp03The analysis uses the C++03 Standard (ISO®/IEC 14882:2003).
cpp11The analysis uses the C++11 Standard (ISO/IEC 14882:2011).
cpp14The analysis uses the C++14 Standard (ISO/IEC 14882:2014).
cpp17The analysis uses the C++17 Standard (ISO/IEC 14882:2017).
This option is available only if you set Source code language (-lang) to
CPP or C-CPP.
If you create a project or options file from your build system using the
polyspace-configure command or
polyspaceConfigure function, the value of this option is
automatically determined from your build system.
If the build system uses different standards for different files, the
subsequent Polyspace analysis can emulate your build system and use different standards
for compiling those files. If you open such a project in the Polyspace user interface, the option value is shown as
defined-by-compiler. However, instead of one
standard, Polyspace uses multiple standards for compiling the files. The analysis uses
the hidden option -options-for-sources to associate different standards with
different files.
Parameter:
-cpp-version |
Value: defined-by-compiler |
cpp03 | cpp11 | cpp14 |
cpp17 |
Default:
defined-by-compiler |
Example (Bug Finder):
polyspace-bug-finder -lang c -sources
|
Example (Code Prover):
polyspace-code-prover -lang c -sources
|
Example (Bug Finder Server): polyspace-bug-finder-server -lang c -sources |
Example (Code Prover
Server):
polyspace-code-prover-server -lang c
-sources |