Main Content

coder.setupMISRAConfig

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

Description

example

coder.setupMISRAConfig(cfg) sets up an Embedded Coder® code generation configuration object with properties selected to improve the generated code compliance with MISRA™ C:2012, MISRA C++:2008, and AUTOSAR C++14 guidelines.

Examples

collapse all

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.

PropertyValue 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'
EnableDynamicMemoryAllocationfalse
EnableOpenMPfalse
EnableRuntimeRecursionfalse
EnableSignedLeftShiftsfalse
EnableSignedRightShiftsfalse
GenerateDefaultInSwitchtrue
HeaderGuardStyle'UseIncludeGuard'
JustifyMISRAViolationstrue
LargeConstantGeneration'KeepInSourceFiles'
MaxIdLength (if target language is C)31
ParenthesesLevel'Maximum'
RuntimeChecksfalse
TargetLangStandard 'C99 (ISO)' for C, 'C++11 (ISO)' for C++

Note

GenerateComments must be set to true to add MISRA and AUTOSAR annotations by using JustifyMISRAViolations.

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

Input Arguments

collapse all

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

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

Version History

Introduced in R2017b