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.
$Mis required.Token Description $MCode generator inserts name mangling text to avoid naming collisions.
Required.
$NCode 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.
$RCode generator inserts the root project name into identifier, replacing unsupported characters with the underscore (_) character.
Customize Identifiers by Using the MATLAB Coder App
Set Build type to one of the following:
Static LibraryDynamic LibraryExecutable
Click 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$NGlobal types $M$NField name of global types $M$NLocal functions $M$NLocal temporary variables $M$NConstant macros $M$NEMX Array Types emxArray_$M$NEMX 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 CustomSymbolStrGlobalVarGlobal variables '$M$N'CustomSymbolStrTypeGlobal types '$M$N'CustomSymbolStrFieldField name of global types '$M$N'CustomSymbolStrFcnLocal functions '$M$N'CustomSymbolStrTmpVarLocal temporary variables '$M$N'CustomSymbolStrMacroConstant macros '$M$N'CustomSymbolStrEMXArrayEMX Array Types 'emxArray_$M$N'CustomSymbolStrEMXArrayFcnEMX 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.