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:

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

  1. Set Build type to one of the following:
    • Static Library
    • Dynamic Library
    • Executable
  2. Click Settings.
  3. 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

  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 theCustomFileNameStr 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 for foo becomesec_foo. If name mangling is required, the generated file name includes the name mangling text.

See Also

coder.EmbeddedCodeConfig

Topics