Identifier Format Control
You can customize generated identifiers by specifying the Identifier format
control parameters on the Code Generation > Identifiers
pane in the Configuration Parameters dialog box. For each parameter, you can enter a macro
that specifies whether, and in what order, certain text is included within generated
identifiers. For example, you can specify that the root model name be inserted into each
identifier using the
The macro can include:
Valid tokens, which are listed in Identifier Format Tokens. You can use or omit tokens depending on what you want to include in the identifier name. The Shared utilities identifier format parameter requires you to specify the checksum token,
$C. The other parameters require the mangling token,
$M. For more information, see Control Name Mangling in Generated Identifiers. The mangling token is subject to the use and ordering restrictions noted in Identifier Format Control Parameter Values.
Token decorators, which are listed in Control Case with Token Decorators. You can use token decorators to control the case of generated identifiers for each token.
Valid C or C++ language identifier characters (
a-z, A-Z, _ , 0-9).
The build process generates each identifier by expanding tokens and inserting the
resultant text into the identifier. The tokens are expanded in the order listed in Identifier Format Tokens. Groups of characters are inserted in the positions that
you specify around tokens directly into the identifier. Contiguous token expansions are
separated by the underscore (
Identifier Format Tokens
This token is required for Shared utilities identifier
format. If the identifier exceeds the Maximum identifier
length, the code generator inserts an 8-character checksum to avoid
naming collisions. The position of the
This token is required. If necessary, the
code generator inserts name-mangling text to avoid naming collisions. Modify
checksum character length by using Shared checksum length
parameter. The position of the
Insert text that you specify for the
Insert method name (for example,
Insert name of object (block, signal or signal object, state, parameter, shared utility function or parameter object) for which identifier is being generated.
Insert root model name into identifier, replacing unsupported characters
with the underscore (
Note: This token replaces the Prefix model name to global identifiers option in previous releases.
Insert tag indicating system hierarchy level. For root-level blocks, the
tag is the text
Note: This token replaces the Include System Hierarchy Number in Identifiers option in previous releases.
Insert data type acronym (for example,
Note: This token replaces the Include data type acronym in identifier option in previous releases.
Insert the name of a storage class that is associated with the data item. This token is also available in the naming rule that you specify for the Header File for a storage class in the Embedded Coder® Dictionary.
Insert the file type.
Identifier Format Control Parameter Values lists the default macro value, the supported tokens, and the applicable restrictions for each Identifier format control parameter.
Identifier Format Control Parameter Values
|Parameter||Default Value||Supported Tokens||Restrictions|
|Field name of global types|
|Subsystem method arguments|
|Local temporary variables|
|Local block output variables|
|Shared utilities identifier format|
|EMX array utility functions identifier
|EMX array types identifier
Non-ERT-based targets (such as the GRT target) implicitly use a default
$R$N$M specification. This default specification consists of the root
model name, followed by the name of the generating object (signal, parameter, state, and so
on), followed by name-mangling text.
Control Case with Token Decorators
On the Code Generation > Identifiers pane, you can use token decorators to control the case of generated
identifiers. Place a decorator immediately after the target token and enclose the decorator
in square brackets
[ ]. For example, you can set Global
$R[uL]$N$M, which capitalizes the first letter
of the model name and forces the remaining characters in the model name to lowercase.
The table shows how to manipulate the expansion of the
$R token for a
model whose name is
|Desired Expansion||Description||Token and Decorator|
|First letter of model name is uppercase. Remaining characters are not modified.|
|First letter of model name is uppercase. Remaining characters are lowercase.|
|All characters are uppercase.|
|All characters are lowercase.|
|First letter of model name is lowercase. Remaining characters are uppercase.|
|First letter of model name is lowercase. Remaining characters are not modified.|
When you use a decorator, the code generator removes the underscore character
_) that appears between tokens by default. However, you can append
each decorator with an underscore:
$R[U_]$N. For example, if you set the
Global variables parameter to
$R[u_]$N[uL]$M for a
modelName and a
DW, the result is
Control Formatting of Identifiers
This example shows how you can customize generated identifiers by specifying the Identifier format control parameters on the Code Generation > Identifiers pane in the Configuration Parameters dialog box. To maintain model traceability, it is important that incremental revisions to a model have minimal impact on the identifier names that appear in the generated code. This example shows how you can use name mangling by specifying the Identifier format control parameters to minimally impact the identifier names.
% Cleanup rtwdemoclean; close_system(model,0)