| MATLAB® | ![]() |
#include "mex.h" int mexAtExit(void (*ExitFcn)(void));
integer*4 mexAtExit(ExitFcn) subroutine ExitFcn()
Pointer to function you want to run on exit
Always returns 0.
Use mexAtExit to register a function to be called just before the MEX-function is cleared or MATLAB software is terminated. mexAtExit gives your MEX-function a chance to perform tasks such as freeing persistent memory and closing files. Typically, the named ExitFcn performs tasks like closing streams or sockets.
Each MEX-function can register only one active exit function at a time. If you call mexAtExit more than once, MATLAB uses the ExitFcn from the more recent mexAtExit call as the exit function.
If a MEX-function is locked, all attempts to clear the MEX-file will fail. Consequently, if a user attempts to clear a locked MEX-file, MATLAB does not call the ExitFcn.
In Fortran, you must declare the ExitFcn as external in the Fortran routine that calls mexAtExit if it is not within the scope of the file.
See mexatexit.c in the mex subdirectory of the examples directory.
mexLock, mexUnlock, mexSetTrapFlag
![]() | matPutVariableAsGlobal (C and Fortran) | mexCallMATLAB (C and Fortran) | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |