Managing error strings in C
Adrian McCarthy
adrian at mti.mti.com
Tue Jan 22 06:33:54 AEST 1991
In article <2271 at wzv.win.tue.nl> wietse at wzv.win.tue.nl (Wietse Venema) writes:
>Error numbers, file names, line numbers etc. are often available as
>global variables. These do not need to be passed to the message
>formatter at all, if it understands format strings that look like:
>
> "Error %{error_number} on line %{line_number}"
>
>and consults the corresponding global variables to do %{...} expansion.
This has its good and bad sides.
Good: It's efficient and solves the problem at hand.
Bad: If the message printer has to know about global variables specific to
a particular program, it can't be re-used in another without modification.
(This could be solved by using a structure that maps names used in the error
messages to global variables used in the particular program. Handling the
various types could be tricky.)
Bad: It tempts programmers to put too much information into global variables
which renders the program difficult to modify and maintain.
Aid. (adrian at gonzo.mti.com)
More information about the Comp.lang.c
mailing list