rcs/diff, and gcc vs cc (FAQ)

Tony Cooper tony at kahu.marcam.dsir.govt.nz
Sat Apr 20 14:56:08 AEST 1991


In article <1991Apr19.151316.26992 at athena.mit.edu>,
sorensen at athena.mit.edu (Alma G. Sorensen) writes:
|> I'm trying to get rcs working under 2.0.
|> 
|> However, when I try to compile gnu's diff-1.15, I get errors:
|> 
|>         gcc -O -DUSG -DSYSV -c diff.c
|> diff.c: In function compare_files:
|> diff.c:504: `S_IFDIR' undeclared (first use this function)
|> diff.c:504: (Each undeclared identifier is reported only once
|> 
|> Strangely, if I use cc instead of gcc, things compile fine!
|> 
I'm not going to tell you how to fix this problem, but tell how to fix this
type of problem.

A/UX can compile programs for several different environments - BSD and SYSV.
The defines -DUSG and -DSYSV do not work in A/UX for defining the SYSV
environment. cc defines the right ones by default, gcc does not. When the
right flags are defined then S_IFDIR gets defined, else it doesn't. Read
the man page for cc(1) for more information.

In general, when a system identifier is not defined, do this: go into the
/usr/include directory and do "fgrep -l S_IFDIR *". If that doesn't find
it try /usr/include/sys or other directories under /usr/include or do a
more sophisticated search of the hierarchy. If you find a .h file that
defines S_IFDIR then examine your program and the .h file to see why it
is not being defined in the program. Usually it is because the .h file
is not included in the program. Sometimes it is because the definition
(as in your case probably) has been 'ifdef'ed out eg
#ifdef SOME_OTHER_SYMBOL
#define S_IFDIR XXXXX
#endif
Then you should make sure that SOME_OTHER_SYMBOL is defined. Get the idea?
You gotta know how the C preprocessor works so you have to have some C
programming knowledge.

Tony Cooper



More information about the Comp.unix.aux mailing list