- To: help-gcc at gnu dot org
- Subject: Strange behavior of preprocessor
- From: David Taylor <dtaylor at ejasent dot com>
- Date: Mon, 24 Sep 2001 22:41:55 -0700
- Organization: Ejasent Inc.
I'm baffled by the behavior of the preprocessor in gcc 2.95.2 on Solaris
7.
For example, this test program includes thread.h, which includes
sys/signal.h, which conditionally includes sys/siginfo.h. But if I copy
/usr/include/sys/signal.h to ./sys and compile with "-I.", the condition
fails and sys/siginfo.h is not included (and a structure definition in
sys/signal.h is skipped, which generates a parse error in thread.h).
The condition in sys/signal.h is:
#if defined(__EXTENSIONS__) || (__STDC__ - 0 == 0) || \
defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
defined(_XPG4_2)
The Sun SparcWorks compiler doesn't do this - the condition succeeds in
both cases.
The steps to reproduce are below.
Any help appreciated.
dtayl
bash-2.03$ cat test.c
#include <thread.h>
int main(int argc, char *argv[])
{
}
bash-2.03$ #Case 1
bash-2.03$ gcc -H test.c
/usr/include/thread.h
/usr/include/sys/signal.h
/usr/include/sys/feature_tests.h
/usr/include/sys/isa_defs.h
/usr/include/sys/unistd.h
/usr/include/sys/siginfo.h
/usr/include/sys/types.h
/usr/include/sys/machtypes.h
/usr/include/sys/int_types.h
/usr/include/sys/select.h
/usr/include/sys/time.h
/usr/include/sys/types.h
/usr/include/time.h
/usr/include/sys/types.h
/usr/include/sys/time_impl.h
/usr/include/sys/select.h
/usr/include/sys/machsig.h
/usr/include/synch.h
/usr/include/sys/machlock.h
/usr/include/sys/synch.h
bash-2.03$ #Case 2
bash-2.03$ mkdir sys; cp /usr/include/sys/signal.h sys
bash-2.03$ gcc -I. -H test.c
/usr/include/thread.h
sys/signal.h
/usr/include/sys/feature_tests.h
/usr/include/sys/isa_defs.h
/usr/include/sys/unistd.h
/usr/include/sys/time.h
/usr/include/sys/types.h
/usr/include/sys/machtypes.h
/usr/include/sys/int_types.h
/usr/include/sys/select.h
/usr/include/sys/time.h
/usr/include/time.h
/usr/include/sys/time_impl.h
/usr/include/synch.h
/usr/include/sys/machlock.h
/usr/include/sys/synch.h
In file included from test.c:1:
/usr/include/thread.h:53: parse error before `*'
/usr/include/thread.h:62: parse error before `*'