| Using the C Math Library | ![]() |
Providing Your Own Print Handler
Instead of calling printf directly, the MATLAB C Math Library calls a print handler when it needs to display an error message or warning. The default print handler used by the library takes a single argument, a const char * (the message to be displayed), and returns void.
static void DefaultPrintHandler(const char *s)
{
printf("%s",s);
}
The routine sends its output to C's stdout, using the printf function.
If you want to perform a different style of output, you can write your own print handler and register it with the MATLAB C Math Library. Any print handler that you write must match the prototype of the default print handler: a single const char * argument and a void return.
To register your function and change which print handler the library uses, you must call the routine mlfSetPrintHandler.
mlfSetPrintHandler takes a single argument, a pointer to a function that displays the character string, and returns void.
void mlfSetPrintHandler ( void ( * PH)(const char *) );
| Defining a Print Handler | Sending Output to a GUI | ![]() |