reusable simulink functions prototype
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello,
I am trying to use reusable simulink functions, and have the functions calls in different referenced models. But when generating c code I get:
Function caller prototype '' is not compatible with function definition.
I put the simulink function declaration in a referenced model "Model_B", but the function definition:
extern real_T Model_B_timestwo(RT_MODEL_Model_B_T * const Model_B_M, const real_T rtu_u);
doesn't match with the called function prototype:
extern real_T Model_B_timestwo(const real_T rtu_u);
This information is missing from the function call: the real time model data structure, and the pointer to the structure. How do I let the function caller know that the function called is a reusable one ? and that he shoulf include an entry point to it?
Best regards.
댓글 수: 0
답변 (1개)
sanidhyak
2025년 9월 1일
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!