Customize Generated Identifiers
If you have Embedded Coder®, you can customize the identifiers in C/C++ code generated from MATLAB® code. For each kind of identifier that you want to customize, set the appropriate identifier format parameter to a macro that specifies the format of the generated identifiers. The macro can include:
Valid C or C++ language identifiers (a-z, A-Z, _, 0–9).
The tokens listed in the following table.
$M
is required.Token Description $M
Code generator inserts name mangling text to avoid naming collisions.
Required.
$N
Code generator inserts the name of the object (global variable, global type, local function, local temporary variable, or constant macro) for which the identifier is generated. Improves readability of generated code.
Required.
$R
Code generator inserts the root project name into identifier, replacing unsupported characters with the underscore (_) character.
Customize Identifiers by Using the MATLAB Coder App
On the Generate Code page, to open the Generate dialog box, click the Generate arrow .
Set Build type to one of the following:
Source Code
Static Library
Dynamic Library
Executable
Click More Settings.
On the Code Appearance tab, under Identifier Format, for each kind of identifier that you want to customize, enter the macro.
Parameter Default Macro Global variables $M$N
Global types $M$N
Field name of global types $M$N
Local functions $M$N
Local temporary variables $M$N
Constant macros $M$N
EMX Array Types emxArray_$M$N
EMX Array Utility Functions emx$M$N
For example, suppose that Global variables has
the value glob_$M$N
. For a global variable named g
,
when name mangling is not required, the generated identifier is glob_g
.
If name mangling is required, the generated identifier includes the
name mangling text.
Customize Generated Identifiers by Using the Command-Line Interface
Create a code configuration object for a library or executable program. For example:
cfg = coder.config('lib','ecoder',true);
For each kind of identifier that you want to customize, specify the macro as a character vector.
Parameter Description Default Macro CustomSymbolStrGlobalVar
Global variables '$M$N'
CustomSymbolStrType
Global types '$M$N'
CustomSymbolStrField
Field name of global types '$M$N'
CustomSymbolStrFcn
Local functions '$M$N'
CustomSymbolStrTmpVar
Local temporary variables '$M$N'
CustomSymbolStrMacro
Constant macros '$M$N'
CustomSymbolStrEMXArray
EMX Array Types 'emxArray_$M$N'
CustomSymbolStrEMXArrayFcn
EMX Array Utility Functions 'emx$M$N'
For example:
cfg.CustomSymbolStrGlobalVar = 'glob_$M$N';
For a global variable named g
, when name
mangling is not required, the generated identifier is glob_g
.
If name mangling is required, the generated identifier includes the
name mangling text.