MATLAB: Are there functions in the generated main function other than “step”, “init”, and “terminate” when I have the atomic subsystems set to “inline”

codeextrafunctiongeneratedinmainpackagine

Why are there functions in my generated main function other than "step", "init", and "terminate" when I have my atomic subsystems set to "inline"?

Best Answer

If you have atomic subsystems that contain other atomic subsystems with function packaging set to "auto", or "nonreusable" this will cause additional functions in the main C file generated.
In that case, the issue can be resolved by changing the function packaging of all atomic subsystems inside any subsystem to "inline". Any option other than inline has the impact of potentially creating global functions which appear on the same level as your step function, or creating function arguments. This can be described in the top of this documentation page here:
If any subsystem inside of an atomic subsystem has the function packaging as "nonreusable" for example, this will cause the function to appear globally on the same level as the step function in the main code generated.
See the attached file as an example. The block "rtwdemo_ssreuse_inception/SS1/SS1" has function packaging set to "nonreusable function" and will show up in the main file. Change this to "inline" to remove it from the main file.
Please note: this example is modified from the demo model presented on the "Function Reuse in Generated Code" documentation page given below.