Mon 05 Apr 2004 09:33:44 PM UTC, original submission:
as reported by Nelson Beebe, current code in info/signals.c does not compile with c89 compilers, for instance:
Machinetype: Sun Ultra 2/2400 (400 MHz); Solaris 2.9
CC=/opt/studio9/SUNWspro/bin/c89
cc: Sun C 5.6 EA1 2003/12/17
The error is:
/opt/studio9/SUNWspro/bin/c89 -DHAVE_CONFIG_H -DLOCALEDIR=\"/usr/local/share/lo\
cale\" -DINFODIR=\"/usr/local/info\" -DINFODIR2=\"/usr/local/share/info\" -I. -\
I. -I.. -I. -I../lib -I../intl -I.. -I. -I/usr/local/include -I/usr/local/inc\
lude -c signals.c
"signals.c", line 116: incomplete struct/union/enum sigaction: old_QUIT
Nelson writes:
I looked at the preprocessor output and system header files, and found
the problem: old_QUIT is declared as
static signal_info old_QUIT;
and signal_info is declared as
typedef struct sigaction signal_info;
However, in a C89 environment, struct sigaction is not exposed in
<sys/signal.h>. It needs either a nonstandard C environment (cc), or
a POSIX, X/OPEN, or XPG environment, because of this wrapper:
#if defined(_EXTENSIONS_) || ((_STDC_ - 0 == 0) && \
!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
(_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
/*
...
#endif
These successfully compile signal.o:
make signals.o CFLAGS='-I/usr/local/include -D_POSIX_SOURCE'
make signals.o CFLAGS='-I/usr/local/include -D_POSIX_C_SOURCE'
make signals.o CFLAGS='-I/usr/local/include -D_XOPEN_SOURCE'
make signals.o CFLAGS='-I/usr/local/include -D_XPG4_2'
Presumably the info program needs signal handling to trap Ctl-C so
that it can restore terminal modes. The question is, can this be done
entirely with the Standard C signalling mechanism, or does it really
need Unix/POSIX/XPG4/XOPEN extensions? If not, it would be better to
make the code strictly Standard-C conformant, since it would then
compile in the maximum number of environments.
|