Main Content

coder.setupMISRAConfig

Configure parameters to improve generated code compliance with MISRA C and C++ 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 and MISRA C++:2008 guidelines.

Examples

collapse all

Create an Embedded Coder code generation configuration object.

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

Set properties that might impact MISRA 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'
CppNamespace

Valid namespace name for C++

DataTypeReplacement'CoderTypedefs'
DynamicMemoryAllocation'Off'
EnableRuntimeRecursionfalse
EnableSignedLeftShiftsfalse
EnableSignedRightShiftsfalse
GenerateDefaultInSwitchtrue
ParenthesesLevel'Maximum'
TargetLangStandard 'C99 (ISO)' for C, 'C++03 (ISO)' for C++

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)

Introduced in R2017b