User`s guide
5 Controlling Code Generation
5-20
Supported Executable Types
Wrapper functions create a link between the Compiler-generated code and a
supported e xecutable type by p r oviding the re quired interface that allows the
code to operate in the desired execution environment.
The wrapper functions differ depending on the execution environment,
whereas the C and C++ head er files and code that are generated by t he
Compiler are the same for MEX-functions, stand-alone appli cations, and
libraries.
To provide the required interface, the wrapper:
•Defines persistent/global variables
•Initializes the
feval function table for r un-t ime feval support
•Performs wrapper-specific initialization and termination
•Initializes the constant pools generated by optimization
This section discusses the various wrappers that can be generated using the
MATLAB Compiler.
Note When the Compiler generates a wrapper function, it must examine all
of the
.m files that will be included into the executable. If you do not include all
the files, the Compiler may not define all of the global variables. Optimized
code will not run at all without initialization.
Generating Files
You can use the -t option of the Compiler to generate source files in addition
to wrapper files. For example,
mcc -W main -h x.m
examines x.m and all M-files referenced by x.m, but generates only the
x_main.c wrapper file. H owever, including the -t option in
mcc -W main -h -t x.m
generates x_main.c, x.c, and all M-files referenced by x.m.