Real-Time Workshop Embedded Coder | ![]() ![]() |
Generate Reusable Code
The Generate reusable code option and the related Reusable code error diagnostic menu let you generate reusable, reentrant code from a model or subsystem. When this option is selected, data structures such as block states, parameters, external outputs, etc. are passed in (by reference) as arguments to model
_step
and other generated model functions. These data structures are also exported via model
.h
.
In some cases, the Real-Time Workshop Embedded Coder may generate code that will compile but is not reentrant. For example, if any signal, DWork
structure, or parameter data has a storage class other than Auto
, global data structures will be generated. To handle such cases, the Reusable code error diagnostic menu is enabled when Generate reusable code is selected. This menu offers a choice of three severity levels for diagnostics to be displayed in such cases:
None
: build proceeds without displaying a diagnostic message.
Warn
: build proceeds after displaying a warning message.
Error
: build aborts after displaying an error message.
In some cases, the Real-Time Workshop Embedded Coder is unable to generate valid and compilable code. For example, if the model contains any of the following, the code generated would be invalid.
In these cases, the build will terminate after reporting the problem.
When Generate reusable code option is not selected (the default), model data structures are statically allocated and accessed directly in the model code. Therefore the model code is neither reusable nor reentrant.
![]() | Generate An Example Main Program | Suppress Error Status in Real-Time Model Data Structure | ![]() |