How to resolve function redefinition and function parameter data type conflicts when adding custom interface functions for SIL testing in Simulink

Hello,My model interface uses a GetSet storage class and I added custom functions when generating C code. It compiles fine, but during SIL testing, there are errors of function redefinition and function parameter conflicts:
1、I added my custom interface externally, and when compiling the generated C code, my custom code was successfully compiled into the generated code. However, during SIL testing, the SIL component also generates a function for my interface, which causes a function redefinition error during SIL testing. How can this be resolve?
2、To avoid compiling my custom functions into the SIL file during SIL testing, I only included the header files of my custom functions. This allows the SIL component to generate properly. However, my custom Set function has two parameters: one is an index value and the other is a float value. In the generated C code, the index is defined as SINT32, so I also use SINT32 in my custom function. But in the SIL-generated component, the Set function interface is also defined, and it uses size_t, which causes a function data type conflict. How can this error be resolved?

댓글 수: 2

Wrap your .c implementations in #ifndef MATLAB_MEX_FILE.
Change SINT32 to size_t in your custom header/source to match the SIL generator.
Ensure #include "rtwtypes.h" is present in your custom header to stay synced with Simulink's types.
Thank you for your reply. I am a bit curious—why is the data type of the index in the generated code SINT, while SIL uses size_t? SINT is my custom type, and the original data type is int.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

질문:

Ke
2026년 1월 26일

댓글:

Ke
2026년 2월 3일 14:25

Community Treasure Hunt

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

Start Hunting!

Translated by