ct_install_error_reporter

The ct_install_error_reporter function installs a callback function for outputting error messages.

Prototype:

Ct_error_reporter ct_install_error_reporter( Ct_error_reporter pR );

Parameters:

pR
A pointer to a function accepting a const char * parameter and returning void. For convenience, the ct.h header typedefs such a pointer as a Ct_error_reporter.

Return Value:

A pointer to the previous error reporting function.

Discussion:

By default, Cheap Threads writes error messages to standard error, followed by a newline. The messages may come from the Cheap Threads software itself, or it may come from the application by a call to ct_report_error().

For Embedded Cheap Threads: if you use ecterror.c instead of cterror,c, the default behaviour is to silently discard a message.

Depending on the environment, neither treatment may be appropriate. By calling ct_install_error_reporter() the application can install its own customized error reporting function, which may display the message in a popup window, write it to a file, log it in a database, or whatever.

The return value enables the application to install an error reporting function temporarily and then restore the previous function.

If it receives a NULL parameter, ct_install_error_reporter() reinstalls the default error reporting function.

Cheap Threads does not change the error reporting function without an explicit call to ct_install_error_reporter(). In particular it does not restore the default function when the scheduler terminates, nor when the application calls ct_clear().

Restrictions:

The ct_install_error_reporter function may be called at any time.
Home