coder.setupMISRAConfig - Configure parameters to improve generated code compliance with MISRA and AUTOSAR guidelines - MATLAB (original) (raw)

Main Content

Configure parameters to improve generated code compliance with MISRA and AUTOSAR guidelines

Syntax

Description

coder.setupMISRAConfig([cfg](#mw%5F71de641a-1ba1-484e-957b-194d35315a86)) sets up an Embedded Coder® code generation configuration object with properties selected to improve the generated code compliance with MISRA™ C:2012, MISRA C:2023, MISRA C++:2008, and AUTOSAR C++14 guidelines.

example

Examples

collapse all

Configure Code Generation Configuration Object for Improved MISRA and AUTOSAR Compliance

Create an Embedded Coder code generation configuration object.

cfg = coder.config('lib', 'ecoder', true);

Set properties that might impact MISRA and AUTOSAR compliance.

coder.setupMISRAConfig(cfg);

The function coder.setupMISRAConfig sets property values according to the values shown in the table.

Property Value for Improved MISRA Compliance
CastingMode 'Standards'
CppGenerateEnumClass (if target language is C++) true
CppInterfaceClassName (if target language is C++) ''
CppInterfaceStyle (if target language is C++) 'Functions'
CppNamespace (if target language is C++) Valid namespace name for C++
DataTypeReplacement 'CoderTypedefs'
EnableDynamicMemoryAllocation false
EnableOpenMP false
EnableRuntimeRecursion false
EnableSignedLeftShifts false
EnableSignedRightShifts false
GenerateDefaultInSwitch true
HeaderGuardStyle 'UseIncludeGuard'
JustifyMISRAViolations true
LargeConstantGeneration 'KeepInSourceFiles'
MaxIdLength (if target language is C) 31
ParenthesesLevel 'Maximum'
RuntimeChecks false
TargetLangStandard 'C99 (ISO)' for C, 'C++11 (ISO)' for C++

Note

GenerateComments must be set totrue to add MISRA and AUTOSAR annotations by usingJustifyMISRAViolations.

If the CppNamespace property is unset, and theTargetLang property is 'C++', thencoder.setupMISRAConfig sets theCppNamespace property to a default character vector,'Codegen'. Modify this value to a namespace name that is particular to your project.

Input Arguments

collapse all

cfg — Embedded Coder code generation configuration object

coder.EmbeddedCodeConfig object

Embedded Coder configuration object for generating C/C++ code from MATLAB® code. Create the object by usingcoder.config.

Example: cfg = coder.config('lib','ecoder',true)

Version History

Introduced in R2017b