Evaluate Your Generated Code for MISRA C Standard Compliance
It is important to check that C code generated by Embedded Coder® from Simulink® and Stateflow® complies with MISRA C:2012 coding standards. This workflow illustrates the process of evaluating your generated code for compliance to MISRA C:2012 guidelines.
Design your model in Simulink or Stateflow.
Open the Model Advisor and run the MISRA C:2012 checks (Simulink Check), which are available in By Task > Modeling Standards for MISRA C:2012.
If necessary, modify the model to adhere to the Modeling Guidelines and Model Advisor Checks for Verifying Compliance with MISRA C Standards.
After the MISRA C:2012 checks pass, generate code by using Embedded Coder.
To avoid possible name clashes, multiple functions definitions, and multiple data definitions, use one of these code generation approaches:
Single model: Generate code from a single model, including submodels, by using Model blocks.
Multiple models: Generate code from multiple models, including:
A shared utility folder to synchronize functions
Data ownership to control data definitions
Hand integration to manage code generated from various models
Run the checkers for MISRA C:2012 Directives and Rules (Polyspace Bug Finder).
For more information about running a Polyspace® analysis on your generated code, including analysis options and results, see:
Bug Finder Analysis in Simulink (Polyspace Bug Finder)
Code Prover Analysis in Simulink (Polyspace Code Prover)
Justify violations to the MISRA C:2012 coding standards using Polyspace annotations (Polyspace Bug Finder).