To comply with code standards and guidelines, integrate generated code with external code, and address memory requirements, you can control the declarations and definitions of functions, variables, and data types in generated code. For example, you can use these graphical and programming interfaces to map model data elements and functions to model-independent code definitions:
In the Code Mappings editor or by using an API, configure default C code generation for categories of model data and functions.
In the Code Mappings editor, override configurations for individual C functions.
In the Model Data Editor code view, override configurations for individual model data elements.
Code Mappings Editor | Associate model data elements and entry-point functions with code definitions |
Environment for Configuring Model Data and Functions for Code Generation
Configure model data and functions for code generation.
Configure Code Generation for Model Entry-Point Functions
Learn about generated entry-point functions and ways to control their interfaces and whether the functions are reusable and reside in specific areas of memory.
Configure Default C Code Generation for Categories of Model Data and Functions
Apply default code generation configurations for categories of model data and functions across a model.
Configure Generated Code According to Interface Control Document Interactively
Configure code generation settings for a model according to specifications from an interface control document.
When you open the Code perspective in a model created before release R2018a, learn how to manage the migration of memory section and shared utility settings.
Choose Storage Class for Controlling Data Representation in Generated Code
Choose a storage class to apply to data elements in a model, such as signals, states, and block parameters.
Configure Data Interface by Applying Storage Classes
Configure data elements in a model, such as block parameters and signal lines, so that corresponding variables appear in generated code.
Apply Storage Classes to Individual Signal, State, and Parameter Data Elements
Control data representation in the generated code by applying storage classes directly, which overrides the default storage classes that you specify in the Code Mapping Editor.
Apply Built-In and Customized Storage Classes to Data Elements
Customize data representation in the generated code by applying storage classes to individual data items.
Control Placement of Global Data Definitions and Declarations in Generated Files
Modularize the generated code and establish clear ownership of global data by controlling the file placement of each declaration and definition.
Protect Global Data with const and volatile Type Qualifiers
Prevent data corruption and improve code safety by applying C type qualifiers
const
and volatile
to global data in generated
code.
Finely Control Data Representation by Writing TLC Code for a Storage Class
For advanced control of data representation in the generated code, create custom storage classes by writing TLC code.
Customize Generated C Function Interfaces
Learn ways that you can configure generated C function interfaces and about customization limitations.
Configure Default C Code Generation for Categories of Model Data and Functions
Apply default code generation configurations for categories of model data and functions across a model.
Override Default Naming for Individual C Entry-Point Functions
Explicitly customize the name individual entry-point functions.
Override Default C Step Function Interface
Explicitly configure step function name and arguments.
Customize Entry-Point Function Interfaces for Simulink Function and Function Caller Blocks
Customize entry-point function names and step function arguments for Simulink Function and Function Caller blocks.
Control Data and Function Interface in Generated Code
Control how generated code exchanges data with a calling environment.
Rapid Prototyping Model Functions
Generate rapid prototyping code.
Control Generation of C++ Class Interfaces
Produce C++ class interfaces in code generated for a model.
Generate C++ Class Interface to Model or Subsystem Code
Generate a C++ class interface to code generated from a model or subsystem.
Generate Code for String Blocks by using the Standard C++ String Library
Generate C++ code for Simulink string blocks.
Generate Modular Function Code for Nonvirtual Subsystems
Generate modular function code for nonvirtual subsystems.