| MATLAB Compiler | ![]() |
Print and Error Handling Functions
By default, MATLAB Compiler-generated applications and shared libraries send printed output to standard output and error messages to standard error. The Compiler generates a default print handler and a default error handler that implement this policy. If you'd like to change this behavior, you must write your own error and print handlers and pass them in to the appropriate generated initialization function.
You may replace either, both, or neither of these two functions. Note that the MCR sends all regular output through the print handler and all error output through the error handler. Therefore, if you redefine either of these functions, the MCR will use your version of the function for all the output that falls into class for which it invokes that handler.
The default print handler takes the following form.
The implementation is straightforward; it takes a string, prints it on standard output, and returns the number of characters printed. If you override or replace this function, your version must also take a string and return the number of characters "handled." The MCR calls the print handler when an executing M-file makes a request for printed output, e.g., via the MATLAB function disp. The print handler does not terminate the output with a carriage return or line feed.
The default error handler has the same form as the print handler.
However, the default implementation of the print handler is slightly different. It sends the output to the standard error output stream, but if the string does not end with carriage return, the error handler adds one. If you replace the default error handler with one of your own, you should perform this check as well, or some of the error messages printed by the MCR will not be properly formatted.
| Library Initialization and Termination Functions | Functions Generated from M-Files | ![]() |
© 1994-2005 The MathWorks, Inc.