Troubleshoot S-Function Build Upgrade
A pre-R2020b model uses S-Functions. When migrating this model to the current release, this S-Function related message appears in the build log:
undefined reference to 'C function in S-Function'
What This Issue Means
In R2020b and later releases, the compiler for model builds changed from a Windows® compatible C compiler to the C++ compiler. To accommodate this change, update S-Function code for C++ compatibility.
Tip
Fortran S-Functions are not supported in R2020b and later releases of Simulink® Real-Time™.
In R2026a and later releases, support is available for the C++ compiler for target computers using the Linux®-based RTOS. To accommodate this addition, update S-Function code for C++ compatibility.
Try This Workaround
To update S-Function code for C++ compatibility, modify the declaration of the S-Function in the header file.
For example, update this C S-Function declaration:
void getAllDataMyFunction(short); void myfunction_initialize(short, unsigned char*, short*); void myfunction_terminate(short, int);
Updated the code to this C++ S-Function declaration:
#ifdef __cplusplus extern "C" { #endif void getAllDataMyFunction(short); void myfunction_initialize(short, unsigned char*, short*); void myfunction_terminate(short, int); #ifdef __cplusplus } #endif
Before building the updated code, remove all artifacts from previous model builds.
See Also
Topics
- Upgrade Advisor: Check model for upgradable Simulink Real-Time features
- Upgrade Advisor: Check model for Simulink Real-Time logging features
- External Code Integration
- Troubleshoot Model Upgrade and Obsolete Blocks
- Troubleshoot System Upgrade
- Troubleshoot MATLAB API Call Upgrade
- Troubleshoot Model Upgrade and Logging Features