| Contents | Index |
Configure how the Simulink Coder code generator inserts comments into generated code, by modifying parameters on the Comments pane.
Note Comments can include international (non-US-ASCII) characters encountered during code generation when found in Simulink block names and block descriptions, user comments on Stateflow diagrams, Stateflow object descriptions, custom TLC files, and code generation template files. |
For descriptions of Comments pane parameters, see Code Generation Pane: Comments in the Simulink Coder reference documentation.
Configure how the Simulink Coder code generator uses symbols to name identifiers and objects by setting parameters on the Symbols pane.
Two options are available for GRT targets: Maximum identifier length and Reserved names. These are the only symbols options for GRT targets.
The Maximum identifier length field allows you to limit the number of characters in function, type definition, and variable names. The default is 31 characters. This is also the minimum length you can specify; the maximum is 256 characters. Consider increasing identifier length for models having a deep hierarchical structure, and when exercising some of the mnemonic identifier options described below.
Within a model containing Model blocks, no collisions of constituent model names can exist. When generating code from a model that uses model referencing, the Maximum identifier length must be large enough to accommodate the root model name and the name mangling string (if any). A code generation error occurs if Maximum identifier length is too small.
When a name conflict occurs between a symbol within the scope of a higher level model and a symbol within the scope of a referenced model, the symbol from the referenced model is preserved. Name mangling is performed on the symbol from the higher level model.
The Reserved names field allows you to specify the set of keywords that the Simulink Coder code generation process should not use, facilitating code integration where functions and variables from external environments are unknown in the Simulink model. For a list of rules for specifying reserved names, see Reserved names in the Simulink Coder reference documentation.
If your model contains MATLAB Function or Stateflow blocks, the Simulink Coder code generation process can use the reserved names specified for those blocks if you select Use the same reserved names as Simulation Target.
If the Embedded Coder product is installed on your system, the Symbols pane expands to include options for controlling identifier formats, mangle length, scalar inlined parameters, and Simulink data object naming rules. For details, see Customize Generated Identifiers in the Embedded Coder documentation.
For descriptions of Symbols pane parameters, see Code Generation Pane: Symbols in the Simulink Coder reference documentation.
Simulink Coder software reserves certain words for its own use as keywords of the generated code language. Simulink Coder keywords are reserved for use internal to Simulink Coder software and should not be used in Simulink models as identifiers or function names. C reserved keywords should also not be used in Simulink models as identifiers or function names. If your model contains any reserved keywords, the code generation build does not complete and an error message is displayed. To address this error, modify your model to use identifiers or names that are not reserved.
If you are generating C++ code using the Simulink Coder software, your model must not contain both the Reserved Keywords for Code Generation and the C++ Reserved Keywords.
Note You can register additional reserved identifiers in the Simulink environment. For more information, see Reserved names in the Simulink Coder reference documentation. |
| auto | double | int | struct |
| break | else | long | switch |
| case | enum | register | typedef |
| char | extern | return | union |
| const | float | short | unsigned |
| continue | for | signed | void |
| default | goto | sizeof | volatile |
| do | if | static | while |
| catch | friend | protected | try |
| class | inline | public | typeid |
| const_cast | mutable | reinterpret_cast | typename |
| delete | namespace | static_cast | using |
| dynamic_cast | new | template | virtual |
| explicit | operator | this | wchar_t |
| export | private | throw |
Reserved Keywords for Code Generation.
| abs | fortran | localZCE | rtNaN |
| asm | HAVESTDIO | localZCSV | SeedFileBuffer |
| bool | id_t | matrix | SeedFileBufferLen |
| boolean_T | int_T | MODEL | single |
| byte_T | int8_T | MT | TID01EQ |
| char_T | int16_T | NCSTATES | time_T |
| cint8_T | int32_T | NULL | true |
| cint16_T | int64_T | NUMST | TRUE |
| cint32_T | INTEGER_CODE | pointer_T | uint_T |
| creal_T | LINK_DATA_BUFFER_SIZE | PROFILING_ENABLED | uint8_T |
| creal32_T | LINK_DATA_STREAM | PROFILING_NUM_SAMPLES | uint16_T |
| creal64_T | localB | real_T | uint32_T |
| cuint8_T | localC | real32_T | uint64_T |
| cuint16_T | localDWork | real64_T | UNUSED_PARAMETER |
| cuint32_T | localP | RT | USE_RTMODEL |
| ERT | localX | RT_MALLOC | VCAST_FLUSH_DATA |
| false | localXdis | rtInf | vector |
| FALSE | localXdot | rtMinusInf |
Simulink Coder Code Replacement Library Keywords. The list of code replacement library (CRL) reserved keywords for your development environment varies depending on which CRLs currently are registered. Beyond the default ANSI, ISO, and GNU CRLs provided with Simulink Coder software, additional CRLs might be registered and available for use if you have installed other products that provide CRLs (for example, a target product), or if you have used Embedded Coder APIs to create and register custom CRLs.
To generate a list of reserved keywords for all CRLs currently registered in your environment, use the following MATLAB function:
crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers()
This function returns an array of CRL keyword strings. Specifying the return argument is optional.
To generate a list of reserved keywords for the CRL that you are using to generate code, call the function passing the name of the CRL as displayed in the Code replacement library menu on the Code Generation > Interface pane of the Configuration Parameters dialog box. For example,
crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)')Here is a partial example of the function output:
>> crl_ids = RTW.TargetRegistry.getInstance.getTflReservedIdentifiers('GNU99 (GNU)')
crl_ids =
'exp10'
'exp10f'
'acosf'
'acoshf'
'asinf'
'asinhf'
'atanf'
'atanhf'
...
'rt_lu_cplx'
'rt_lu_cplx_sgl'
'rt_lu_real'
'rt_lu_real_sgl'
'rt_mod_boolean'
'rt_rem_boolean'
'strcpy'
'utAssert'Note Some of the returned keyword strings appear with the suffix $N, for example, 'rt_atan2$N'. $N expands into the suffix _snf only if nonfinite numbers are supported. For example, 'rt_atan2$N' represents 'rt_atan2_snf' if nonfinite numbers are supported and 'rt_atan2' if nonfinite numbers are not supported. As a precaution, you should treat both forms of the keyword as reserved. |
For GRT, GRT-malloc and RSim targets, the Simulink Coder code generator automatically constructs identifiers for variables and functions in the generated code. These symbols identify
Signals and parameters that have Auto storage class
Subsystem function names that are not user defined
All Stateflow names
The components of a generated symbol include
The root model name, followed by
The name of the generating object (signal, parameter, state, and so on), followed by
A unique name mangling string
The name mangling string is conditionally generated to resolve potential conflicts with other generated symbols.
The length of generated symbols is limited by the Maximum identifier length parameter specified on the Symbols pane of the Configuration Parameters dialog box. When there is a potential name collision between two symbols, a name mangling string is generated. The string has the minimum number of characters required to avoid the collision. The other symbol components are then inserted. If Maximum identifier length is not large enough to accommodate full expansions of the other components, they are truncated. To avoid this outcome, it is good practice to:
Avoid name collisions. For example, avoid using default block names (for example, Gain1, Gain2...) when the model includes multiple blocks of the same type. Also, make subsystems atomic and reusable.
Where possible, increase the Maximum identifier length parameter to accommodate the length of the symbols you expect to generate.
Maximum identifier length can be longer for a top model than referenced models. Model referencing can involve additional naming constraints. For information, see Configuring Generated Identifiers and Parameterizing Model References.
The Embedded Coder product provides additional flexibility over how symbols are constructed, by using a Symbol format field that controls the symbol formatting in much greater detail. See Configure Symbols in the Embedded Coder documentation for more information.
![]() | Select the Target Language | Debug | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |