Main Content

Check MISRA C++:2023 (-misra-cpp-2023)

Check for violations of MISRA C++:2023 rules and directives

Since R2024b

Description

Specify whether to check for violation of MISRA™ C++:2023 rules and directives1 . Each value of the option corresponds to a subset of rules to check.

Set Option

User interface (desktop products only): In your project configuration, the option is on the Coding Standards & Code Metrics node. See Dependency for other options that you must also enable.

User interface (Polyspace Platform, desktop products only): This option does not exist in the project configuration. Activate checkers by using the options Use custom checkers file and Checkers activation file (-checkers-activation-file).

Command line and options file : Use the option -misra-cpp-2023. See Command-Line Information.

Why Use This Option

Use this option to specify a subset of MISRA C++:2023 rules and directives that Polyspace® checks.

After analysis, the Results List pane lists the coding standard violations. On the Source pane, for every coding rule violation, Polyspace assigns a symbol to the keyword or identifier relevant to the violation.

Settings

Default: mandatory-required

mandatory

Check for mandatory guidelines.

mandatory-required

Check for mandatory and required guidelines.

  • Mandatory guidelines: Your code must comply with these guidelines.

  • Required guidelines: You may deviate from these guidelines. However, you must complete a formal deviation record, and your deviation must be authorized.

single-unit-rules

Check a subset of rules that apply only to single translation units. These rules are checked in the compilation phase of the analysis.

system-decidable-rules

Check rules in the single-unit-rules subset and some rules that apply to the collective set of program files. The additional rules are the less complex rules that apply at the integration level. These rules can be checked only at the integration level because the rules involve more than one translation unit. These rules are checked in the compilation and linking phases of the analysis.

all

Check for mandatory, required, and advisory guidelines.

from-file

Specify an XML file where you configure a custom selection of checkers for this coding standard. To create a configuration file, click , then select the rules and recommendations you want to check for this coding standard from the right pane of the Checkers selection window. Save the file.

To use or update an existing configuration file, in the Checkers selection window, enter the full path to the file in the field provided or click Browse.

If you set the option to from-file, enable Set checkers by file (-checkers-selection-file).

Dependency

This option is available only if you set Source code language (-lang) to CPP or C-CPP.

For projects with mixed C and C++ code, the MISRA C++:2023 checker analyzes only .cpp files.

Command-Line Information

Use the command -misra-cpp-2023 in the command line to check for violations of MISRA C++ rules.

Parameter: -misra-cpp-2023
Value: mandatory | mandatory-required | single-unit-rules | system-decidable-rules | all | from-file
Example (Bug Finder): polyspace-bug-finder -sources file_name -misra-cpp-2023 all
Example (Bug Finder Server): polyspace-bug-finder-server -sources file_name -misra-cpp-2023 all

Alternatively, enable all or specific MISRA C++:2023 rules through a checkers activation XML file. See Checkers activation file (-checkers-activation-file).

Version History

Introduced in R2024b


1  MISRA is a registered trademark of MIRA Ltd., held on behalf of the MISRA Consortium.