strings in defs.h force recompiles w
jim at ISM780B.UUCP
jim at ISM780B.UUCP
Sun Nov 4 03:41:16 AEST 1984
I have a different approach, which avoids the problem of having to have
def.h track strings.c, and of having the name of the string separate from
its text. strings.c looks like
char NEWS_VERSION[] = "B 2.10.2 9/5/84";
char DFLTSUB[] = "general,all.general";
char TMAIL[] = "/usr/ucb/Mail";
char ADMSUB[] = "general,all.announce";
char PAGE[] = "/usr/ucb/more";
char NOTIFY[] = "usenet";
char DFTXMIT[] = "uux - -r -z %s!rnews < %s";
char UXMIT[] = "uux -r -z -c %s!rnews '<' %s";
char DFTEDITOR[] = "vi";
Either declare these in defs.h,
extern char NEWS_VERSION[],
DFLTSUB[],
...
or only where needed. The latter would avoid remaking everything whenever
you add or delete a string.
One thing to watch out for in this scheme or the
strings[n] scheme is that you can't take sizeof the strings.
You also cannot use them as initializers. But for common use as error
formats or pathnames, this works pretty well.
-- Jim Balter, INTERACTIVE Systems (ima!jim)
More information about the Comp.lang.c
mailing list