Main Content

C standard version (-c-version)

Specify C language standard followed in source code

Description

Specify the C language standard that you follow in your source code. This option applies to both dynamic testing and static analysis.

Set Option

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.

User interface (Polyspace Platform, desktop products only): In your project configuration, the option is on the Target & Compiler node of the Build tab. See Dependencies for ways in which the source code language can be automatically determined.

Command line and options file: Use the option -c-version. See Command-Line Information.

Why Use This Option

Use this option so that Polyspace® can allow features specific to a C standard version during compilation. For instance, if you compile with GCC using the flag -ansi or -std=c90, specify c90 for this option. If you are not sure of the language standard, specify defined-by-compiler.

For instance, suppose you use the boolean data type _Bool in your code. This type is defined in the C99 standard but unknown in prior standards such as C90. If the Polyspace compilation follows the C90 standard, you can see compilation errors.

Some MISRA C™ rules are different based on whether you use the C90 or C99 standard. For instance, MISRA C C:2012 Rule 5.2 requires that identifiers in the same scope and name space shall be distinct. If you use the C90 standard, different identifiers that have the same first 31 characters violate this rule. If you use the C99 standard, the number of characters increase to 63.

Settings

Default: defined-by-compiler

defined-by-compiler

The analysis uses a standard based on your specification for Compiler (-compiler).

See C/C++ Language Standard Used in Polyspace Analysis.

c90

The analysis uses the ISO®/IEC 9899:1990 standard, informally referred to as the C90 standard.

c99

The analysis uses the ISO/IEC 9899:1999 standard, informally referred to as C99 standard.

c11

The analysis uses the ISO/IEC 9899:2011 standard, informally referred to as the C11 standard..

See also C11 Language Elements Supported in Polyspace.

c17

The analysis uses the ISO/IEC 9899:2018 standard, informally referred to as the C17 or C18 standard.

This version addresses defects in C11 Standard but does not introduce new language features. The value of the __STDC_VERSION__ macro is increased to 201710L.

Dependencies

  • This option is available only if you set Source code language (-lang) to C 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 the hidden option -options-for-sources to associate different standards with different files.

Command-Line Information

Parameter: -c-version
Value: defined-by-compiler | c90 | c99 | c11 | c17
Default: defined-by-compiler
Example (Bug Finder): polyspace-bug-finder -lang c -sources "file1.c,file2.c" -c-version c90
Example (Code Prover): polyspace-code-prover -lang c -sources "file1.c,file2.c" -c-version c90
Example (Bug Finder Server): polyspace-bug-finder-server -lang c -sources "file1.c,file2.c" -c-version c90
Example (Code Prover Server): polyspace-code-prover-server -lang c -sources "file1.c,file2.c" -c-version c90