Preserve MATLAB namespaces in generated code - Specify whether generated code for enumeration in MATLAB namespace includes the namespace in the type definition - MATLAB (original) (raw)
Main Content
Specify whether generated code for enumeration in MATLAB namespace includes the namespace in the type definition
Since R2025a
Model Configuration Pane: Code Generation / Interface
Description
The Preserve MATLAB namespaces in generated code parameter specifies whether the code generator includes the namespace in the generated type definition of an enumerated type that is derived from a Simulink.IntEnumType
object and is defined inside a MATLAB namespace. For C++ code generation, the code generator generates the enumeration in a namespace. For C code generation, the code generator prefixes the enumeration with the MATLAB namespace.
This table displays the generated code for enumerated type Colors
in the MATLAB namespace MyColors
with the parameter set toOn
and Off
.
Language | On | Off |
---|---|---|
C | typedef enum { black, white, } MyColors_Colors; | typedef enum { black, white } Colors; |
C++ | namespace MyColors { enum class Colors : int32_t { black, white }; } | enum class Colors : int32_t { black, white }; |
Settings
On
(default) | Off
On
The generated type definition includes the MATLAB namespace where the enumeration is defined.
Off
The generated type definition does not include the MATLAB namespace where the enumeration is defined.
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | No impact |
Safety precaution | No impact |
Programmatic Use
Parameter: PreserveMATLABNamespacesInGeneratedCode |
---|
Type: character vector |
Values: 'on' | 'off' |
Default: 'on' |
Version History
Introduced in R2025a