Main Content

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 parameterCustomFileNameStrto a macro. The macro can include:

  • Valid file name characters.

  • The tokens listed in the following table.$Mand$Nare 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应用程序

  1. On theGenerate Codepage, to open theGeneratedialog box, click theGeneratearrow.

  2. SetBuild typeto one of the following:

    • 源代码

    • Static Library

    • Dynamic Library

    • Executable

  3. ClickMore Settings.

  4. 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 forfoobecomesec_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

  1. Create a code generation configuration object for a library or executable program. For example:

    cfg = coder.config('lib','ecoder',true);

  2. Specify the file name macro as a character vector in theCustomFileNameStrobject property. For example:

    cfg.CustomFileNameStr ='ec_$N$M';

    For an entry-point function calledfoo, when name mangling is not required, the generated file name forfoobecomesec_foo. If name mangling is required, the generated file name includes the name mangling text.

See Also

Related Topics