Code interface packaging
Description
Select the packaging for the generated C or C++ code interface.
Category: Code Generation > Interface
Settings
Default:
Nonreusable function
if parameter
Language is set to C
;
C++ class
if Language is set to
C++
C++ class
Generate a C++ class interface to model code. The generated interface encapsulates required model data into C++ class attributes and model entry point functions into C++ class methods.
For a model configured with a service interface, this parameter setting is not relevant and, therefore, is not supported.
Nonreusable function
Generate nonreusable code. Model data structures are statically allocated and accessed by model entry point functions directly in the model code.
Reusable function
Generate reusable, multi-instance code that is reentrant, as follows:
For a GRT-based model, the generated
source file contains an allocation function that dynamically allocates model data for each instance of the model. For an ERT-based model, you can use parameter Use dynamic memory allocation for model initialization to control whether an allocation function is generated.model
.cThe generated code passes the real-time model data structure in, by reference, as an argument to
and the other model entry point functions.model
_stepThe real-time model data structure is exported with the
header file.model
.h
For an ERT-based model,
If the model is configured with a service interface, this setting is not supported.
You can use parameter Pass root-level I/O as to control how root-level input and output arguments are passed to the reusable model entry-point functions. They can be included in the real-time model data structure that is passed to the functions, passed as individual arguments, or passed as references to an input structure and an output structure.
Tips
Entry points are exported with
. To call the entry-point functions from handwritten code, add anmodel
.h#include model.h
directive to the code.When you select
Reusable function
, the code generator generates a pointer to the real-time model object (
).model
_MWhen you select
Reusable function
, the code generator can generate code that compiles but is not reentrant. For example, if a signal, DWork structure, or parameter data has a storage class other thanAuto
, global data structures are generated.
Dependencies
The value
C++ class
is available only if parameter Language is set toC++
.Selecting
Reusable function
orC++ class
enables parameter Multi-instance code error diagnostic.For an ERT-based system target file, selecting
Reusable function
enables parameters Pass root-level I/O as and Use dynamic memory allocation for model initialization.To enable parameter Classic call interface, select
Nonreusable function
.For an ERT-based system target file, selecting
C++ class
enables the following model configuration controls for customizing the model class interface:Data Member Visibility/Access Control subpane
Parameters Generate destructor and Use dynamic memory allocation for model block instantiation
For an ERT-based system target file, you can select
Reusable function
with the staticert_main.c
module, if you do the following:Set parameter Pass root-level I/O as to
Part of model data structure
.Select parameter Use dynamic memory allocation for model initialization.
For an ERT-based system target file, you cannot select
Reusable function
if you are:Customizing the
model_step
function prototypeSelecting subsystem block parameter Function with separate data
Using a subsystem that
Has multiple ports that share source
Has a port that is used by multiple instances of the subsystem and has different sample times, data types, complexity, frame status, or dimensions across the instances
Has output marked as a global signal
For each instance contains identical blocks with different names or parameter settings
Selecting
Reusable function
does not change the code generated for function-call subsystems.
Command-Line Information
Parameter:
CodeInterfacePackaging |
Type: character vector |
Value:
'C++ class' | 'Nonreusable function' |
'Reusable function' |
Default:
'Nonreusable function' if TargetLang is
set to 'C' ; 'C++ class' if
TargetLang is set to 'C++' |
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | No impact |
Efficiency | Reusable function or C++
class |
Safety precaution | No impact |
See Also
Related Topics
- Model Configuration Parameters: Code Generation Interface
- Configure Generated C Function Interface for Model Entry-Point Functions
- Generate Reentrant Code from Top Models
- Combine Code Generated for Multiple Models or Multiple Instances of a Model
- Generate Reentrant Code from Top Models
- Generate C++ Class Interface to Model or Subsystem Code
- Interactively Configure C++ Interface (Embedded Coder)
- Generate Reentrant Code from Subsystems
- S-Functions for Code Reuse
- Static Main Program Module (Embedded Coder)
- Configure Generated C Function Interface for Model Entry-Point Functions (Embedded Coder)
- Generate Modular Function Code for Nonvirtual Subsystems (Embedded Coder)
- Generate Component Source Code for Export to External Code Base (Embedded Coder)