All functions are declared by the file clw.h When the safety library is used, the results are similar to the original code, but an exception is printed (to stderror) if an unsafe situation occurred. The flow remains predictable in all circumstances. This is shown in example 4. Here the result of example 3 is given. As all three function calls where used unsafe, three exceptions are printed.
ERROR: Exception 65536 : fopen : Permission denied Problem occured at: Function main() at line 8 of "test.c" ERROR: Exception 64 : (f)printf : illegal stream Problem occured at: Function main() at line 9 of "test.c" ERROR: Exception 64 : fclose : illegal stream Problem occured at: Function main() at line 10 of "test.c"(Output of example 4)
Normally the printf statement would cause the system to malfunction (or to crash). Using the alternative function will cause an exception to be thrown, which can be handled by an installed exception handler. The default exception handler will simply print it, as shown. The shown exception numbers are documented in the file and can be used to distinguish between different types of exceptions.