Main Content

Customize Generated File Names

The code generator creates model.* files during the code generation and build process. When you generate C/C++ code for ERT-based models, you can customize the names of the generated header, source, and data files. You cannot customize the generated files for referenced models. Custom file names enable you to:

  • Comply with naming standards of the company or industry.

  • Integrate with external code.

In the Configuration Parameters dialog box, on the Code Generation > Code Placement pane, use the Auto-generated file naming rules group to customize the names of generated files. When you use Modular or Compact(with separate date file) file packaging, you can specify custom names for generated header, source, and data files. When you use Compact file packaging, you can specify custom names for generated header and source files.

  1. Open any ERT-based model, for example, rtwdemo_dynamicio. In the Configuration Parameters dialog box, change the System target file to ert.tlc.

  2. On the Code Generation > Code Placement pane, select File packaging format as Compact(with separate date file).

  3. Specify custom file names by using the naming rules for these parameters:

    $E is mandatory for Header files and Source files. $E represents these instances of file types:

    • capi

    • capi_host

    • dt

    • testinterface

    • private

    • types

  4. To build the model, press Ctrl + B. In the code generation report, the generated files are listed on the left pane under Model files and Data files section.

    In this example, $E resolves to private and types. The generated header files resolve to the model name with the value for $E and custom text header. The generated source files resolve to the model name with custom text source. The generated data file resolves to the model name with custom text data. Here is a summary of naming rules applied and the corresponding generated files:

    Type of FileToken SpecificationCustom TextGenerated File Name
    Header file$R$Eheaderrtwdemo_dynamicio_header.h
    Header file$R$Eheaderrtwdemo_dynamicio_private_header.h
    Source file$R$Esourcertwdemo_dynamicio_source.c
    Header file$R$Eheaderrtwdemo_dynamicio_types_header.h
    Data file$Rdatartwdemo_dynamicio_data.c

Related Topics