Main Content

Support C++ Class Interface Control

This section describes how to configure a custom embedded target to support C++ class interface control. Without the described modifications, you will not be able to use C++ class code interface packaging to generate and configure C++ class interfaces to model code. For more information about C++ class interface control, see Interactively Configure C++ Interface (Embedded Coder).

About C++ Class Interface Control and Custom Targets

The requirements for supporting C++ class interface control are as follows:

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

Declaring C++ Class Interface Control Compliance

To declare C++ class interface control compliance for your target, you must implement a callback function that sets the CPPClassGenCompliant 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 CPPClassGenCompliant flag as follows:

slConfigUISetVal(hDlg,hSrc,'CPPClassGenCompliant','on');
slConfigUISetEnabled(hDlg,hSrc,'CPPClassGenCompliant',false);
hSrc.getConfigSet.refreshDialog;

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

When the CPPClassGenCompliant target configuration parameter is set to on, you can use the C++ class code interface packaging to generate and configure C++ class interfaces to model code.

Providing C++ Class Interface Control Support in the Custom Static Main Program

Selecting C++ class code interface packaging for your model enables model configuration parameter Generate an example main program. When you select this parameter,the code generator produces an example main program, ert_main.cpp. The generated example main program declares model data and calls the C++ class interface configured model step method, and illustrates how the generated code can be deployed.

To customize the build process and disable generation and inclusion of an example main program, see the setTargetProvidesMain (Embedded Coder) function. Disabling example main generation permits including a custom main program.

Related Topics