How do I customize the name of shared utility functions for C/C++ or AUTOSAR code generated by the Embedded Coder?

26 visualizaciones (últimos 30 días)
I am using Embedded Coder to generate code for my Simulink model. During code generation, some shared utility files (for example, for Lookup Tables) are also generated with the code that will be used by multiple functions in the generated code. I want to customize the identifiers of the generated shared utility files if possible, and also add a custom prefix or suffix to the file names.

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 19 de Nov. de 2025 a las 0:00
Editada: MathWorks Support Team el 19 de Nov. de 2025 a las 20:12
This is documented on the "Configure Naming of Generated Functions " section of the "Generate Shared Utility Code" page.
There are two ways of customizing shared utility function names:
  • Using Embedded Coder Dictionary & Code Mappings Editor (R2018b+)
  • Using the “Shared utilities identifiers format” model parameter

OPTION 1: Embedded Coder Dictionary & Code Mappings Editor

For ERT-based targets (C only), in the Embedded Coder Dictionary, define a function customization template that specifies a custom function naming rule. For example, in order to add a custom prefix "myPrefix_" to the file names, specify the Naming Rule "myPrefix_$N$C":
 For more information on tokens, see Identifier Format Control.
Then, in the Code Mappings editor or by using the code mappings programming interface, map the Shared utility function category to that template:

OPTION 2: Using the “Shared utilities identifiers format” parameter

For C++ ERT-based targets, AUTOSAR (Classic/Adaptive AUTOSAR and C++/DDS), or any releases older than R2018b, you can use the “Shared utilities identifiers format” (CustomSymbolStrUtil) model parameter:
To add a custom prefix "myPrefix_" to the file names, you can make use of the “$U” token which inserts the custom text specified in the option “Custom token text" (CustomUserTokenString). The following configuration will apply the desired naming scheme for the file names:
  • Shared utilities identifier format: $U_$N$C
  • Custom token text: myPrefix
The same is illustrated in the image below: 
You can also modify the above parameters by using the following MATLAB commands:
>> set_param(bdroot, 'CustomSymbolStrUtil', '$U_$N$C')
>> set_param(bdroot, 'CustomUserTokenString', 'myPrefix')
See the Shared utilities identifier format documentation page for more details about the tokens supported by this option.
NOTE: In R2021a through R2022a, if a "slprj" folder or other cached files exist from a previous build, you may not see the correct naming convention for the utility function when using "CustomSymbolStrUtil". See the bug report for more information: https://www.mathworks.com/support/bugreports/2660030

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by