User`s guide
5 Controlling Code Generation
5-22
MEX-Files
The -W mex -L C options produce the MEX-file wrapper, which includes the
mexFunction interface that is standard to all MATLAB plug-ins. For more
information about the requirements of the
mex interface, see External
Interfaces/API in the MATLAB documentation.
In addition to declaring globals and initializing the
feval function table, the
MEX-file wrapper function includes interface and definition functions for all
M-files not included into the set of compiled files. These functions are
implemented as callbacks to MATLAB.
Note By default, the -x option does not include any functions that do not
appear on the command line. Functions that do not appear on the command
line would generate a callback to MATLAB. Specify
-h if you want all
functions called to be compiled into your MEX-file.
Main Files
You can generate C or C++ application wrappers that are suitable for building
C or C++ stand-alone applications, respectively. These POSIX-compliant main
wrappers accept strings from the POSIX shell and return a status code. They
are meant to translate “command-like” M-files into POSIX main applications.
POSIX Main Wrapper
The POSIX main() function wrapper behaves exactly the same as the
command/function duality mode of MATLAB. That is, any command of the
form
command argument
can also be written in the functional form
command('argument')
If you write a function that accepts strings in MATLAB, that function will
compile to a POSIX main wrapper in such a way that it behaves the same from
the DOS/UNIX command line as it does from within MATLAB.