Customize C/C++ File Names Generated from MATLAB Code - MATLAB & Simulink (original) (raw)
Main Content
If you have Embedded CoderĀ®, you can customize the file names of the C/C++ code generated from MATLABĀ® code. By changing the file names, you can avoid name clashes when integrating different C/C++ code projects together. Customize the file names by setting the file name format parameter CustomFileNameStr
to a macro. The macro can include:
- Valid file name characters.
- The tokens listed in the following table.
$M
and$N
are required.
Token | Description |
---|---|
$M | Code generator inserts name mangling text to avoid naming collisions.Required. |
$N | Code generator inserts the non-customized file name.Required. |
$R | Code generator inserts the root project name into the file name, replacing unsupported characters with the underscore (_) character. |
By default, the macro is set to $N$M
.
Customize File Names by Using the MATLAB Coder App
- Set Build type to one of the following:
Static Library
Dynamic Library
Executable
- Click Settings.
- Enter the macro on the Code Appearance tab, next toGenerated source and header files:
For example, suppose you set the macro to the value ec_$N$M
. For an entry-point function called foo
, when name mangling is not required, the generated file name for foo
becomes ec_foo
. If name mangling is required, the generated file name includes the name mangling text.
Customize Generated File Names by Using the Command-Line Interface
- Create a code generation configuration object for a library or executable program. For example:
cfg = coder.config('lib','ecoder',true); - Specify the file name macro as a character vector in the
CustomFileNameStr
object property. For example:
cfg.CustomFileNameStr = 'ec_$N$M';
For an entry-point function calledfoo
, when name mangling is not required, the generated file name forfoo
becomesec_foo
. If name mangling is required, the generated file name includes the name mangling text.