Ralf Wildenhues wrote: > This one is funny: Tru64 5.1 cc, which is > Compaq C V6.5-303 (dtk) on Compaq Tru64 UNIX V5.1 (Rev. 732) > > treats include_next different from include: > > $ echo '#define foo bar > #include <foo.h>' | cc -E - > # 1 "" > > > cc: Error: , line 2: Cannot find file <foo.h> specified in #include > directive. (noinclfile) > #include <foo.h> > -^ > > $ echo '#define foo bar > #include_next <foo.h>' | cc -E - > # 1 "" > > > cc: Error: , line 2: Cannot find file <bar.h> specified in #include > directive. (noinclfile) > #include_next <foo.h> > -^
A very peculiar preprocessor behaviour, indeed. > Consequently, it fails like this when building gnulib: > > source='../../gllib/accept4.c' object='accept4.o' libtool=no \ > DEPDIR=.deps depmode=tru64 /bin/ksh ../../build-aux/depcomp \ > cc -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" -I. > -I../../gllib -I.. -I../intl -ieee -g -c -o accept4.o ../../gllib/accept4.c > cc: Severe: ./fcntl.h, line 46: Cannot find file <rpl_fcntl.h> specified in > #include directive. (noinclfilef) > #include_next <fcntl.h> > -^ > gmake[4]: *** [accept4.o] Error 1 > > I'm not sure how to best avoid this for the two include_next instances > in fcntl.h. Suggestions? You will notice that 1) the '#define fcntl rpl_fcntl' occurs only after '#define _GL_FCNTL_H'. So, whenever #include_next <fcntl.h> behaves like this, _GL_FCNTL_H must be already defined. 2) the #include_next <fcntl.h> is guarded by a #ifndef _GL_FCNTL_H The only explanation therefore is that the problem occurs due to fcntl.in.h doing # include <unistd.h> which itself then again does # include <fcntl.h> For a fix, one of the two include statements need to be conditionalized so that it does not happen any more on this platform. Since I've never heard that <fcntl.h> would require <unistd.h> as a prerequisite (e.g. the manual page of 'open' does not mention <unistd.h>), I propose this change: 2010-01-17 Bruno Haible <br...@clisp.org> Avoid compilation error with cc on OSF/1 5.1. * lib/fcntl.in.h: Include <unistd.h> after the #include_next <fcntl.h> statement, not before. Reported by Ralf Wildenhues. --- lib/fcntl.in.h.orig Sun Jan 17 22:02:28 2010 +++ lib/fcntl.in.h Sun Jan 17 22:02:03 2010 @@ -27,7 +27,6 @@ #include <sys/types.h> #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ # include <sys/stat.h> -# include <unistd.h> #endif #...@include_next@ @NEXT_FCNTL_H@ @@ -39,7 +38,6 @@ #include <sys/types.h> #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ # include <sys/stat.h> -# include <unistd.h> #endif /* The include_next requires a split double-inclusion guard. */ #...@include_next@ @NEXT_FCNTL_H@ @@ -47,6 +45,10 @@ #ifndef _GL_FCNTL_H #define _GL_FCNTL_H +#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ +# include <unistd.h> +#endif + /* The definition of GL_LINK_WARNING is copied here. */