Main Content

S-Function Compatibility

User-written level-2 S-functions are backward compatible in terms of their source code (C/C++). An S-function written in an older release that is recompiled in a newer release retains the functionality and behavior from the older release.

In addition, user-written level-2 S-function MEX files are backward compatible. For each release, all example S-function MEX files included in the previous 10 releases of MATLAB® on the Windows® platform are tested for backward compatibility. In general, S-function MEX files created more than 10 releases before a new release can work in a new release if the platform and associated libraries either remain unchanged or maintain backward compatibility.


If a user-written S-function contains code that depends on additional libraries (e.g., by using the ‘-l’ option with the MEX command), S-function compatibility might not be supported with a library update, a newer release of MATLAB, or a platform upgrade.

For best results, recompile the S-function source code in your current version of MATLAB. For more information on MEX compatibility, see MEX Version Compatibility.

C++ S-Functions compiled with MinGW®- w64 compiler need to be recompiled with a newer version of the compiler or a different compiler to work with MATLAB R2020a or a later release.