Previous: Introduction, Up: Introduction


2.1 Usage

The tracefct library is initialized with tf_init(). This should be called before any other routine, as it registers the name of the executable. Directly after entering a function, tf_enter() should be called with the name of the function. Before leaving a function tf_leave() should be called. If a fatal error occurs, tf_exit() should be called with a return value that will be passed to the invoking process and a message to be written to stderr. Interesting return values are predefined in the exiterrvals.h header file. tf_exit() does not return to the calling function, but calls exit(). Warning or diagnostic messages may be written via tf_message or tf_vmessage. The function stack may be written at any time with tf_dump_stack().

tracefct has a predefined output stream of stderr. However, it is sometimes useful to have the output sent to another file instead. This is accomplished with the tf_open function. In the case that the tracefct is not to stderr, the standard prefix is not printed. The output stream may be reset to stderr with the tf_close function. Note that the tf_exit will write both to stderr and the tracefct output stream, provided that they are different.