Code interface packaging (subcomponent) - Package generated code interface for model subcomponent as reusable or nonreusable
functions or as a C++ class - MATLAB ([original](https://in.mathworks.com/help/rtw/ref/codeinterfacepackagingsubcomponent.html)) ([raw](?raw))
Main Content
Package generated code interface for model subcomponent as reusable or nonreusable functions or as a C++ class
Since R2025a
Model Configuration Pane: Code Generation / Interface
Description
The Code interface packaging (subcomponent) parameter specifies how the code generator packages generated C or C++ interface code for subcomponents (model references).
Settings
Reusable function
(default) | Nonreusable function
| C++ class
Reusable function
Generates reusable, multi-instance code for the subcomponent that is reentrant. This setting is the default when Language is set toC
.
To enable this value, set the Total number of instances allowed per top model parameter to Multiple
. WhenTotal number of instances allowed per top model is set toMultiple
, this value is automatically selected.
You cannot select Reusable function
if the subcomponent contains a subsystem that:
- Has the subsystem block parameter Function packaging configured as
Nonreusable function
. - Assigns a global storage class to an output signal.
Nonreusable function
Generates nonreusable code for the subcomponent. The code generator allocates model data structures statically. Generated entry-point functions access the data structures directly.
To enable this value, set the Total number of instances allowed per top model parameter to Zero
orOne
. When Total number of instances allowed per top model is set to Zero
orOne
, this value is automatically selected.
You cannot select Nonreusable function
for the subcomponent while the Code interface packaging (component) parameter for the root model is set to Reusable function
.
If the System target file parameter is set to an ERT-based system target file:
- Selecting
Nonreusable function
enables theImplement root-level I/O as parameter. UseImplement root-level I/O as to control how root-level input and output arguments are passed to subcomponent model entry-point functions. For instance, you can pass the arguments individually or as global variables.
C++ class
Generates a C++ class interface for the subcomponent. The generated interface encapsulates required model data into C++ class attributes and model entry-point functions into C++ class methods.
This setting is the default when Language is set toC++
.
If the Code interface packaging (component) parameter is set toC++ class
, this value is automatically configured, and no other values are allowed.
For a model configured with a service code interface, this parameter setting is not relevant and thus is not supported.
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | Reusable function or C++ class |
Safety precaution | No impact |
Programmatic Use
Parameter: SubcomponentCodeInterfacePackaging | |
---|---|
Type: character vector | |
Values:'C++ class' |'Nonreusable function' | 'Reusable function' |
Default: 'Reusable function' if TargetLang is set to'C'; 'C++ class' if TargetLang is set to 'C++' |
Version History
Introduced in R2025a