User`s guide

Creating More Complex C MEX S-Functions
3-11
The following headers are included by matlabroot/simulink/include/
simstruc.h
when compiling as a MEX-file.
When compiling your S-function with for use with the Real-Time Workshop,
simstruc.h includes.
Statements Required at the Bottom of S-Functions
Include this trailer code at the end of your C MEX S-function main module
only:
#ifdef MATLAB_MEX_FILE /* Is this being compiled as MEX-file? */
#include "simulink.c" /* MEX-file interface mechanism */
#else
#include "cg_sfun.h" /* Code generation registration func */
#endif
These statements select the appropriate code for your particular application.
Table 3-2: Header Files Included by Simstruc.h When Compiling as a MEX-File
Header File Description
matlabroot/extern/include/tmwtypes.h Generaldatatypes,e.g.,
real_T
matlabroot/extern/include/mex.h
MATLAB MEX-file API
routines
matlabroot/extern/include/matrix.h MATLAB MEX-file API
routines
Table 3-3: Header Files Included by Simstruc.h When Used
by the Real-Time Workshop
Header File Description
matlabroot/extern/include/tmwtypes.h General types, e.g. real_T
matlabroot/rtw/c/libsrc/rt_matrx.h
Macros for MATLAB API
routines