Main Content

ssDeclareFunctionCaller

Declare Simulink function call with a given function prototype.

Syntax

void ssDeclareFunctionCaller(SimStruct *S, char *fcnPrototype)

Arguments

S

SimStruct that represents an S-Function block.

fcnPrototype

Function prototype of the Simulink® function.

Returns

No return value.

Description

ssDeclareFunctionCaller is required to declare the Simulink function prototype to be called in the compile-time method mdlInitializeSizes. ssCallSimulinkFunction calls a declared Simulink function at run-time.

Examples

Note

ssDeclareFunctionCaller may only be called in mdlInitializeSizes.

Example 1

char fcnPrototype[] = "y = timestwo(u)";
ssDeclareFunctionCaller(S, fcnPrototype);

Example 2

To call a Simulink function outside of the model hierarchy with non-default argument specifications (not real double scalars), use ssDeclareSimulinkFunction to declare the Simulink function with NULL as the fcnPtr argument. Use the following macros to set the datatype, dimension, and complexity: ssSetSimulinkFunctionArgDataType, ssSetSimulinkFunctionArgDimensions, ssSetSimulinkFunctionArgComplexity. Use ssDeclareFunctionCaller to declare the function caller.

char fcnPrototype[] = "y=foo(u)";

/* Declare the external function as NULL*/
ssDeclareSimulinkFunction(S, fcnPrototype, NULL, SS_GLOBAL_VISIBILITY);

/* Specify function argument dimensions*/
size_t dims[1] = {3};
ssSetSimulinkFunctionArgDimensions(S, "foo", "u", 1, dims);
ssSetSimulinkFunctionArgDimensions(S, "foo", "y", 1, dims);

/* Call an external function*/
ssDeclareFunctionCaller(S, fcnPrototype);

Languages

C, C++

Version History

Introduced in R2018a