Using the C++ Math Library    

Providing Your Own Print Handler

By default, the library sends output to the C++ standard output stream, cout. However, instead of sending output directly to the standard output stream, the MATLAB C++ Math Library calls a print handler when it needs to display an error message or warning. The print handler used by the library takes a single argument, a const char * (the message to be displayed), and returns void.

The default print handler:

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 signature of the default print handler: a single const char * argument and a void return.

To register your function and change which print handler is used, you must call the routine mwSetPrintHandlermwSetPrintHandler takes a single argument, a pointer to a function that displays the character string, and returns void.


 Printing, Exceptions, and Memory Management Using the Print Handler to Print Your Own Messages