Model configuration parameters allow you to configure the appearance of the generated code. You can change the style of comments in the code, modify how identifiers are generated, specify code style, and modify code generation template files to specify custom file and function banners.
Add selected data object property values as a comment in the general code above that data object identifier.
Add global comments to a Simulink® model so that the comment text appears where you specify in the generated files.
This example shows how to turn on comments in the generated code that suppress error detection through Polyspace.
Correlate code generated for a MATLAB Function block with MATLAB® source code.
You can customize generated identifiers by specifying the Identifier format control parameters on the Code Generation > Identifiers pane in the Configuration Parameters dialog box.
Use the Maximum identifier length parameter to limit the number of characters in function, type definition, and variable names.
Specify a set of names that the code generation process should not use.
Customize the naming of identifiers in the generated code.
Specify parameter values to avoid identifier name collisions with referenced models.
Specify the position and length of name-mangling text in generated identifiers.
Integrate the generated code with your code by specifying
the identifiers that correspond to Boolean
Also, specify the identifiers that correspond to data type limits,
which the generated code uses to determine overflows.
If you use the code generator to produce C or C++ code, your model must not contain keywords that are reserved for internal use.
To verify your model, you can trace back and forth between generated identifiers and corresponding entities within the model.
There are some exceptions to identifier formatting conventions for type names,
Auto storage classes, and shared utilities.
There are some limitations pertaining to how autogenerated identifiers comply with the setting of the Maximum identifier length parameter.
Describes how to convert if-elseif-else code to switch-case statements to enhance readability of generated code.
Convert if-elseif-else code to switch-case statements.
Generate a single unique variable for each Data Store read and write operation and thereby enhance Data Coherency.
Specify how parentheses are placed in the code.
Reorder the execution of operands in the generated code to improve efficiency.
Specify if a default case is generated among switch-case statements.
Specify whether to replaces multiplication by powers of two with signed bitwise shifts.
Specify whether the generated code contains right shifts on signed integers.
Control the data type casts that the code generator specifies in the generated code.
Custom file processing (CFP) tools allow you to customize the organization and formatting of generated code.
Code Generation Template (CGT) files define the top-level organization and formatting of generated source code and header files.
A custom file processing (CFP) template imposes a simple structure on the code generation process.
Create CGT files and CFP templates to use custom file processing features.
Using code generation template (CGT) files, you can specify custom file banners and function banners for the generated code files.
Use data and code templates to change the organization of generated files.
Customize generated file names by using file naming rules.
This example shows you the process of generating a simple source (
.cpp) and header (
.h) file using the example CFP template.
You can use a template to define what code the code generator adds to the generated file, control the location of code in the file, and optionally insert comments in the generated file.
The code template API includes functions to obtain the names of the standard model files and other model-related information.
This topic describes template symbols and rules for using them.