Undefined function and variable handling
Handling for undefined functions and variables in custom code
Model Configuration Pane: Simulation Target
Description
The Undefined function and variable handling parameter specifies how to
handle undefined functions and variables in the C source code file
of a model that contains Stateflow® charts or C Caller, C
Function, MATLAB Function, or
MATLAB System blocks. If you declare a function
or variable in the header file but do not implement it in the source
code, Simulink® behaves according to this setting. Depending on the
setting, Simulink takes functions and variables from the header file and
creates stub functions and variables equal to zero if they are not
defined in the C source code file. If your code is not compatible
with desktop simulation, or you want to introduce the interface to
external code with the relevant header files, set this parameter to
Use interface only.
Settings
Throw errorReturn an error if a function or variable in the C source code is undefined. Simulink does not generate stub functions or variables equal to zero, but shows the functions and variables in the Port Specification table of the C Caller block.
Filter outFilter out undefined functions and variables in the C source code. Simulink does not automatically generate stub functions or variables equal to zero, and the Port Specification table of the C Caller block does not show these functions and variables.
If you have undefined functions or variables in the C source code and a model that contains a Stateflow chart, MATLAB Function, or MATLAB System block calls these functions or variables, Simulink returns an error. If the custom code in the blocks in your model has undefined functions or variables, Simulink displays a warning.
Do not detectDo not detect undefined functions or variables in the source code. Simulink does not automatically generate stub functions or variables equal to zero, but shows the functions and variables in the Port Specification table of the C Caller block.
Use interface onlyDetect undefined functions and variables in the C source code. Simulink generates stub functions and variables equal to zero, makes them visible in the model, and allows you to call them from Stateflow charts and C Function, MATLAB Function, and MATLAB System blocks.
Recommended Settings
| Application | Setting |
|---|---|
| Debugging | No impact |
| Traceability | No impact |
| Efficiency | No recommendation |
| Safety precaution | No recommendation |
Programmatic Use
Parameter: CustomCodeUndefinedFunction |
Value: "ThrowError" | "FilterOut" | "DoNotDetect" | "UseInterfaceOnly" |
Default: "FilterOut" |
Version History
Introduced in R2020b