Tennis wrote:
Does anyone know of a utility that automatically manages the message
format, labeling and numbering of messages during collaborative program
development?
In the example below, the values "foo-001", "foo-002" would be
auto-generated and managed by the utility:
if ( problem == FILE_IO) {
printf("foo-001 File IO failed\n");
}
if ( problem == FILE_MISSING) {
printf("foo-002 File missing!\n");
}
The object, of course, is to keep the programmer from manually creating
and managing the values.
Depending on what you need, you may be able to use fairly
straight-forward C coding:
problist.h"
PROB(FILE_IO, "File IO Failed"),
PROB(FILE_MISSI NG, "File missing!"),
....
code.c:
/* Assign error numbers to list */
#define PROB(name,str) name
enum {
NOPROB = 0, /* first error will be 1 */
#include "problist.h "
NPROBS
};
/* Store problem strings */
#undef PROB
#define PROB(name,str) str
const char * const errmsg[] = {
"OK",
#include "problist.h "
};
....
problem = FILE_IO;
...
if (problem) {
printf ("foo-%3d - %s\n", problem, errmsg[problem]);
}
You probably want to change some details, but the gist is that one file,
problist.h here, contains a list of problem identifiers and strings.
The compiler assigns increasing error codes and stores the strings in a
table.
You could also write a simple program, using the same header, to
generate a list of error codes and strings.
Thad