Customize C/C++ File Names Generated fromMATLABCode
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 parameterCustomFileNameStr
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 theMATLABCoder应用程序
On theGenerate Codepage, to open theGeneratedialog box, click theGeneratearrow.
SetBuild typeto one of the following:
源代码
Static Library
Dynamic Library
Executable
ClickMore Settings.
Enter the macro on theCode Appearancetab, next toGenerated source and header files:
For example, suppose you set the macro to the valueec_$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.
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 called
foo
, 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.