Main Content

Undefined function and variable handling

Description

Specify the behavior of 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.

Category: Simulation Target

Settings

Default: Filter out

Throw error

Return 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 out

Filter 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 detect

Do 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 only

Detect 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.

Command-Line Information

Parameter: CustomCodeUndefinedFunction
Value: 'ThrowError' | 'FilterOut' | 'DoNotDetect' | 'UseInterfaceOnly'
Default: 'FilterOut'

Recommended Settings

ApplicationSetting
DebuggingNo impact
TraceabilityNo impact
EfficiencyNo recommendation
Safety precautionNo recommendation

Related Topics