Main Content

Support C Function Prototype Control

This section describes how to configure a custom embedded target to support function prototype control. Without the described modifications, you will not be able to use available interfaces for customizing entry-point function interfaces. For more information, see Configure C Code Generation for Model Entry-Point Functions (Embedded Coder).

About C Function Prototype Control and Custom Targets

The requirements for supporting C function prototype control are as follows:

For an example that shows how to configure custom target optional features, see Customize System Target Files.

Declaring C Function Prototype Control Compliance

To declare C function prototype control compliance for your target, you must implement a callback function that sets the ModelStepFunctionPrototypeControlCompliant flag, and then install the callback function in the SelectCallback field of the rtwgensettings structure in your system target file. The callback function is triggered whenever the user selects the target in the System Target File Browser. For example, the following system target file code installs a SelectCallback function named custom_select_callback_handler:

rtwgensettings.SelectCallback = 'custom_select_callback_handler(hDlg,hSrc)';

The arguments to the SelectCallback function (hDlg, hSrc) are handles to private data used by the callback API functions. These handles are restricted to use in system target file callback functions. They should be passed in without alteration.

Your callback function should set the ModelStepFunctionPrototypeControlCompliant flag as follows:


For more information about the system target file callback API, see the slConfigUIGetVal, slConfigUISetEnabled, and slConfigUISetVal function reference pages.

When the ModelStepFunctionPrototypeControlCompliant target configuration parameter is set to on, you can use the Configure C Step Function Interface dialog box to control the function prototype of the base-rate step function generated for a rate-based model.

Providing C Function Prototype Control Support in the Custom Static Main Program

If your target uses a custom static main program, and if a nondefault function prototype control configuration is associated with a model, you must update the static main program to call the function prototype controlled initialize and step functions. You can do this in either of the following ways:

  1. Manually adapt your static main program to declare model data and call the function prototype controlled initialize and step functions.

  2. Generate your main program by selecting model configuration parameter Generate an example main program. The generated main program declares model data and calls the function prototype controlled initialize and step function.

Related Topics