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

40 visualizaciones (últimos 30 días)
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 comentarios
Will
Will el 29 de En. de 2026 a las 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 el 3 de Feb. de 2026 a las 14:25
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by