I understand that you are trying to use reusable Simulink functions across different referenced models. When generating the C code, the issue which you faced usually occurs because by default, a referenced model generates a model data structure argument “(RT_MODEL_*)” in the function definition:
extern real_T Model_B_timestwo(RT_MODEL_Model_B_T * const Model_B_M, const real_T rtu_u);
while the caller expects a simpler reusable prototype:
extern real_T Model_B_timestwo(const real_T rtu_u);
The mismatch actually arises due to model reference interface settings and function packaging options.
To resolve this, kindly follow the steps below:
1. Open your referenced model (“Model_B”)
2. Go to Code Mappings > Functions
3. For your Simulink Function (“timestwo”), set:
- “Function Packaging = Reusable function”
4. In Model Settings (Ctrl+E) > Code Generation > Interface:
- Set Code interface packaging = Reusable function
- Disable "Pass root-level I/O as structure reference"
- Disable "Use model data structure"
5. In Code Mappings > Inports/Outports:
- Set storage class to Auto or ExportedGlobal
6. Now, regenerate code. The new generated prototype will be:
extern real_T Model_B_timestwo(const real_T rtu_u);
matching the caller function signature and hence resolving the incompatibility.
Kindly refer to the following official documentation for more details:
Cheers & Happy Modeling!
