Is C preprocessor test in configure script correct?

rchmielarz .
Mon Jan 15 09:27:00 GMT 2018


I was trying to bootstrap gcc for netbsd and I have found the following

In gcc/configure (around line 5585 for gcc 7.2.0) it says:
"  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
  # <limits.h> exists even on freestanding compilers.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#ifdef __STDC__
# include <limits.h>
# include <assert.h>
             Syntax error

This is the test that is checking if C preprocessor is working. But neither
limits.h nor assert.h were in my system includes as we have no includes in
build directory at this point. But as I read the comment the intention of
this test is to look for the header files provided with gcc itself and not
the system wide includes. Hence following CPP reference ( when I have changed
the snippet to use # include "limits.h" and # include "assert.h" it worked
as it first looked in current dir and only then in system wide includes.

This check goes back to at least gcc 4.8.5 and I'm building the gcc with
7.2.0 on my host machine. Am I correct in this change? I would appreciate
any comments on this. And if I'm correct could this be changed in the
upstream gcc?


More information about the Gcc-help mailing list