For your generated C code to adhere to code standards and guidelines or to more easily integrate that code with Simulink® functions, you can customize the name of an entry-point function, for example, initialize, execution, terminate.
This example shows how to change the name of the initialize
function
for model rtwdemo_fcnprotoctrl
.
Open and save a copy of model rtwdemo_fcnprotoctrl
in a writable location.
Open the Embedded Coder app.
Click the Code Mappings - C tab.
In the Code Mappings editor, click the Functions tab.
Change the function name by using one of these methods:
In the Function Name column, enter a name for the function.
In the Function Preview column, click the function prototype hyperlink to open a configuration dialog box. In the C Initialize Function Name field, enter the function name. Click Apply to verify the change in the C function prototype field or click OK to exit the dialog box and view the function name in the Function Preview column of the Code Mappings editor.
For this example, change the name of the initialize
function to fcnprotoctrl_init
.
Save the model.
Generate code.
Verify the changes in the generated code. In the Code view, find
instances of function name fcnprotoctrl_init
. The function name appears
in generated files rtwdemo_fcnprotoctrl.h
and
rtwdemo_fcnprotoctrl.c
.
In rtwdemo_fcnprotoctrl.h
:
extern void fcnprotoctrl_init(void);
In rtwdemo_fcnprotoctrl.c
:
void fcnprotoctrl_init(void) { ... }