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

34 views (last 30 days)
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 Comments
Will
Will on 29 Jan 2026 at 16:41
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.
Ke
Ke 2 minutes ago
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.

Sign in to comment.

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!