Why is a function definition not generated for Simulink functions that are not called in Simulink?

4 views (last 30 days)
I am trying to generate code for a model that contains a Simulink function that is not called.
In releases prior to R2018b, I am getting the following error in code generation:
"Simulink Coder does not support models containing Simulink functions that are not called"
In some other releases, I have observed that I can generate code but the function definition is not being generated, and I do not get any header file for it.
Is this expected behaviour? How has this evolved through the different MATLAB releases?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Sep 2020
Please let me clarify the changes in behaviour below for the different MATLAB releases:
  • For releases prior to R2018b, we provide the error message that you reported ("Simulink Coder does not support models containing Simulink functions that are not called"). This is expected behaviour, as for these MATLAB releases it was a business decision not to support this workflow.
  • From R2018b to R2019b, the error message was relaxed to a warning, to allow users generate code even though a Simulink function without a caller was present. However, support for generating function definition was still not incorporated.
  • From R2020a onwards, the function definition is generated even though the Simulink function is not called. We still provide the warning message to inform the user.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!