Manage Build Process File Dependencies
An important control of the size of generated code is managing the number and size of included files (dependencies). To reduce the number of system header files and generated header files that generated code requires, it is helpful to understand the dependencies that the build process generates and the conditions that lead to dependencies.
The dependency relationships among generated source and header files appear in the figure. Arrows coming from a file point to files it includes. Other dependencies exist, for example, on Simulink®header filestmwtypes.h
andsimstruc_types.h
, plus C or C++ library files. The figure maps inclusion relations between only those files that are generated in the build folder. These files can reference utility and model reference code located in a code generation folder. For more information about the folders and files that the build process creates, seeManage Build Process FoldersandManage Build Process Files.
The two tables identify the conditions that control creation of dependency files for GRT and ERT targets. To manage build-related dependencies, consider how these conditions apply to your model and code generation process. Then, configure model parameters and code generation options to manage build process file dependencies.
Due to differences in file packaging options for code generated with ERT-based system target files, the file dependencies differ slightly from file packaging for code generated with GRT-based system target files. SeeManage File Packaging of Generated Code Modules(Embedded Coder).
The parent system header files (
) include child subsystem header files (model
.h
). In more layered models, subsystems similarly include their children's header files in the model hierarchy. As a consequence, subsystems are able to view recursively into their descendant subsystems and view into the root system because everysubsystem
.h
orsubsystem
.c
includessubsystem
.cpp
andmodel
.h
.model
_private.h
In the figure, files
,model
.h
, andmodel
_private.h
depend on the header filesubsystem
.hrtwtypes.h
. If you use system target files that are not based on the ERT system target file, the source files that you generate can have additional dependencies ontmwtypes.h
andsimstruc_types.h
.
System Header Files
系统头文件使函数声明, type definitions, and macro definitions available to the legacy or external code. Some code generation scenarios require including header files that are specific to the code generator product.
The code generator includes some system header files for broadly defined cases. For example, generated code includes
when the model contains a utility function that requires this header file. This approach helps identify header file dependencies:
Set model configuration parameterShared code placementto
'Shared location'
and build the model. The code generator places the utility functions in__sharedutils
folder.Use a find-in-file utility (for example, grep utility) to search the
.c
and.h
files in the__sharedutils
folder for#include
. The search results list the utilities with header file dependencies.使用此信息来识别工具雷莫ve from the model and reduce header file dependencies in the generated code.
For more information, seeGenerate Shared Utility Code for Fixed-Point Functions.
System Header File | Description and Inclusion Conditions for GRT or ERT System Target Files |
---|---|
Defines math constants GRT—Generated code does not include this file. ERT—Generated code includes this file when the code honors your model configuration for solverStop timeand either:
|
|
Provides floating-point math functions 当你莫GRT-Generated代码包括这个文件del contains a floating-point math function. ERT—Generated code includes this file when your model contains a floating-point math function, unless a code replacement library entry overrides the function. For more information, seeChoose a Code Replacement Library. |
|
Defines NULL GRT and ERT—Generated code includes this file when your model contains a utility function that requires this file. |
|
Provides file I/O functions 当你莫GRT-Generated代码包括这个文件del includes aTo Fileblock. ERT—Generated code includes this file when either:
|
|
Provides utility functions such as the integer versions of GRT—Generated code includes this file when either:
ERT—Generated code includes this file when either:
|
|
Provides memory functions such as 当你莫GRT-Generated代码包括这个文件del initialization code calls ERT—Generated code includes this file when a block or model initialization code calls For a list of relevant blocks, in the Command Window, type:
Look for blocks with the N2 note. To omit calls to |
Code Generator Header Files
Dependencies in the table for generated header files apply to the system target filesgrt.tlc
andert.tlc
. System target files derived from these base system target files can have additional header dependencies. Code generation for blocks from blocksets, embedded targets, and custom S-functions can introduce additional header dependencies.
Header File | Description and Inclusion Conditions for GRT or ERT System Target Files |
---|---|
|
Defines an enumerated type corresponding to built-in data types GRT and ERT—Generated code includes this file when one or more of these conditions apply:
|
|
Defines data structures for external mode GRT and ERT—Generated code includes this file when your model configuration enables external mode. |
|
Defines external mode functions GRT and ERT—Generated code includes this file when your model configuration enables external mode. |
|
Provides fixed-point support for noninlined S-functions GRT—Generated code includes this file. ERT—Generated code includes this file when either:
|
|
Contains type definitions for timing bridges GRT and ERT—Generated code includes this file when building a reference model or building a model that contains model blocks. |
|
Defines model-specific data types GRT and ERT—Generated code includes this file. |
|
Contains type definitions for multiword-wide data types and their word-size chunks GRT and ERT—Generated code includes this file when one or more of these conditions apply:
For a model that uses multiword data types, the code generator overwrites the file if the data types are greater in length than those of the model for which code was last generated. To avoid overwriting this file, set:
|
|
Support nonfinite numbers GRT—Generated code includes this file when one or more of these conditions apply:
ERT—Generated code includes this file when one or more of these conditions apply:
|
|
Contains type definitions for special mathematical constants (such as π ande) and defines the GRT and ERT—Generated code includes this file when either:
|
|
Supports MAT-file logging and includes: rtwtypes.h builtin_typeid_types.h multiword_types.h rt_mxclassid.h rtw_matlogging.h GRT—Generated code includes this file. ERT—Generated code includes this file when you model configuration selects parameterMAT-file logging. SeeMAT-file logging. |
|
Defines GRT and ERT—Generated code includes this file when the code includes |
|
Supports continuous time GRT—Generated code includes this file when the code includes ERT—Generated code includes this file when your model configuration selects parameterSupport: continuous timeand when the code does not already include |
|
Supports external mode GRT—Generated code includes this file when the code includes ERT—Generated code includes this file when your model configuration selects external mode and when the code does not already include |
|
Supports MAT-file logging GRT—Generated code includes this file when the code includes ERT—Generated code includes this file when the code includes |
|
Supports continuous states GRT—Generated code includes this file when the code includes ERT—Generated code includes this file when your model configuration selects parameterSupport: continuous timeand when the code does not already include |
|
Defines code generator data types GRT—Generated code includes this file. Uses a verbose version of the file, which includes ERT—Generated code includes this file. Seertwtypes.h. The code generator overwrites the previously generated rtwtypes.h when you enable (previously disabled) support for:
To avoid rewriting
|
|
Supports calling noninlined S-functions that use the limits.h string.h tmwtypes.h simstruc_types.h GRT—Generated code includes this file. ERT—Generated code includes this file when either:
|
|
Provides definitions that the generated code uses and includes the header files: rtw_matlogging.h rtw_extmode.h rtw_continuous.h rtw_solver.h sysran_types.h GRT—Generated code includes this file when the code includes ERT—Generated code does not include this file. For ERT, |
|
Supports external mode GRT—Generated code includes this file when the code includes ERT—Generated code includes this file when your model configuration selects external mode and when the code does not already include |
|
Contains zero-crossing definitions for models with triggered subsystems where the trigger is rising, falling, or either. File is generated only if required by the model as determined by the data type of the trigger signal. For example, if the data type of the trigger signal is Boolean, zero-crossing detection is not needed. GRT—Generated code does not include this file for GRT code generation targets. ERT—Generated code includes this file when a model has a conditionally executed subsystem where a trigger uses zero crossing detection. If generated, the content of |