Check configuration parameters for MISRA C:2012
mathworks.misra.CodeGenSettings
Dependencies: Embedded Coder® and Simulink® Check™
Usage: C/C++ Code Generation and High-Integrity System Modeling
Guideline: hisl_0060: Configuration parameters that improve MISRA C:2012 compliance
Description
Use this check to identify configuration parameters that can impact MISRA C:2012 compliant code generation. Following the recommendations of this check increases the likelihood of generating MISRA C:2012 compliant code for embedded applications.
Recommended Actions and Results
Review the violations that are flagged by the check and the recommended action for fixing the issue. After applying the changes, save the model and rerun the check analysis.
You can use the Fix button to allow the Model Advisor to fix all flagged violations. For this check, the Model Advisor changes the parameter values to the recommended values.
Note
For models with a GRT-based target, the Model Advisor does not update the System target file configuration parameter to an ERT-based system.
The tables list recommended parameter settings based on their location in the Configuration Parameters dialog box.
Math and Data Types
| Modeling Condition | Recommended Action | 
|---|---|
| Model configuration parameter
                                        Use division for fixed-point net slope
                                        computation is not set to
                                         | Set model configuration parameter Use division for
                                        fixed-point net slope computation to
                                         | 
| Model configuration parameter
                                        Inf or NaN block output is set to
                                         Model
                                    configuration parameter Inf or NaN block
                                        output is set to
                                         | When Support: non-finite
                                        numbers is set to
                                         When
                                        Support: non-finite
                                        numbers is set to
                                         | 
| Model configuration parameter Model Verification
                                    block enabling is set to Use local
                                    settingsorEnable
                                    All. | Set model configuration parameter Model Verification block
                                    enabling to Disable
                                    All. | 
| Model configuration parameter
                                    Undirected event broadcasts is set to noneorwarning. | Set model configuration parameter Undirected event
                                    broadcasts to error. | 
| Model configuration parameter Wrap on
                                    overflow is set to None. | Set model configuration parameter Wrap on
                                    overflow to warningorerror. | 
Hardware Implementation
| Modeling Condition | Recommended Action | 
|---|---|
| Model configuration parameter Signed
                                    integer division rounds to is set to Undefined. | Set model configuration parameter Signed integer division rounds to to ZeroorFloor. | 
| Model configuration parameter Shift right on a signed integer as arithmetic shift is selected. | Clear model configuration parameter Shift right on a signed integer as arithmetic shift. | 
Simulation Target
| Modeling Condition | Recommended Action | 
|---|---|
| Model configuration parameter
                                    Compile-time recursion limit for MATLAB
                                    functions is set to a value other than 0. | Set model configuration parameter Compile-time recursion limit
                                    for MATLAB functions to 0. | 
| Model configuration parameter Dynamic memory allocation in MATLAB functions is selected. | Clear model configuration parameter Dynamic memory allocation in MATLAB functions. | 
| Model configuration parameter Enable run-time recursion for MATLAB functions is selected. | Clear model configuration parameter Enable run-time recursion for MATLAB functions. | 
Code Generation
| Modeling Condition | Recommended Action | 
|---|---|
| Model configuration parameter
                                        Bitfield declarator type
                                        specifier is set to  
 
 | Set model configuration parameter Bitfield declarator type
                                    specifier to uint_T. | 
| Model configuration parameter Casting
                                    modes is not set to Standards
                                    Compliant. | Set model configuration parameter Casting modes to Standards Compliant. | 
| Model configuration parameter Code replacement
                                    library is not set to NoneorAUTOSAR
                                    4.x. | Set model configuration parameter Code replacement
                                        library to  | 
| Model configuration parameter External mode is selected. | Clear model configuration parameter External mode. | 
| Model configuration parameter Generate shared constants is selected. | Clear model configuration parameter Generate shared
                                    constants. For more information, see GenerateSharedConstantsin Model Configuration Parameters: Code Generation Interface. | 
| Model configuration parameter Include comments is cleared. | Select model configuration parameter Include comments. | 
| Model configuration parameter MAT-file logging is selected. | Clear model configuration parameter MAT-file logging. | 
| For ERT-based target systems, configuration parameter MATLAB user comments is cleared. | Select model configuration parameter MATLAB user comments. | 
| A value for configuration parameter Maximum identifier length is not provided. | Set the value of model configuration parameter Maximum identifier
                                    length based on the limits for your
                                implementation. The default value is 31. | 
| Model configuration parameter Parentheses
                                    level is not set to Standards
                                    (Parentheses for Standards Compliance)orMaximum (Specify precedence with
                                    parentheses). | Set model configuration parameter Parentheses
                                    level to Standards (Parentheses for
                                    Standards Compliance)orMaximum
                                    (Specify precedence with parentheses). | 
| For ERT-based target systems,
                                    configuration parameter Preserve static keyword in
                                        function declarations is cleared when
                                        File packaging format is set to
                                         | Select model configuration parameter Preserve static keyword in function declarations. | 
| Model configuration parameter Replace multiplications by powers of two with signed bitwise shifts is selected. | Clear model configuration parameter Replace multiplications by powers of two with signed bitwise shifts. | 
| Model configuration parameter Shared code
                                    placement is set to Auto. | Set model configuration parameter Shared code
                                        placement to  | 
| For ERT-based target systems, configuration parameter Support: continuous time is selected. | Clear model configuration parameter Support: continuous time. | 
| For ERT-based target systems, configuration parameter Support non-inlined S-functions is selected. | Clear model configuration parameter Support non-inlined S-functions. | 
| Model configuration parameter Suppress generation of default cases for switch statements if unreachable is selected. | Clear model configuration parameter Suppress generation of default cases for Stateflow switch statements if unreachable. | 
| Model configuration parameter
                                    System-generated identifiers is set
                                to Classic. | Set model configuration parameter System-generated
                                    identifiers to Shortened. | 
| Model configuration parameter System target file is set to a GRT-based target. | Set model configuration parameter System target file to an ERT-based target. | 
| Model configuration parameter Use dynamic memory
                                    allocation for model initialization is selected
                                when Code Interface Packaging is set to Reusable Function. | Clear model configuration parameter Use dynamic memory allocation for model initialization. | 
Parameter subchecks depend on the results of the parameter noted with D in the results table. When the result status is
                D-Warning, the Current Value column in the
            results table reads Prerequisite constraint not met for the
            subchecks. After you change the parameter, rerun the check.
Note
Some subchecks are specific to configuration parameters for ERT-based systems. These parameters are not updated when you use the Fix button unless you change the model to an ERT-based system.
Capabilities and Limitations
- Displays the settings of the following parameters as additional information in the check results: 
- Does not review referenced models 
- Does not require model compilation 
Version History
Introduced in R2017b
See Also
Topics
- Check Your Model Using the Model Advisor
- Address Model Check Results
- Save and View Model Advisor Check Reports
- Improve Simulation Performance Using Performance Advisor
- Upgrade Models Using Upgrade Advisor
- Use Model Advisor Configuration Editor to Customize Model Advisor (Simulink Check)
- Exclude Blocks from Model Advisor Check Analysis (Simulink Check)
- Justify Model Advisor Violations from Check Analysis (Simulink Check)
- Check Model Compliance Using Edit-Time Checking (Simulink Check)
- Check Model Compliance by Using the Model Advisor (Simulink Check)
- Model Advisor Checks for MISRA C:2012 Coding Standards (Simulink Check)
- MISRA C
- MISRA C:2012 Compliance Considerations