Thanks for reporting this; I didn't realize it was a regression. -Wundef is a bit controversial, but it's easy for Autoconf to support its use for programmers that prefer it, so I installed the following patch. 2006-08-15 Paul Eggert <eggert@xxxxxxxxxxx> * NEWS: Autoconf now uses constructs like "#ifdef HAVE_STDLIB_H" rather than "#if HAVE_STDLIB_H", so that it now works with "gcc -Wundef -Werror". Problem reported by David Fang in <http://lists.gnu.org/archive/html/autoconf/2006-08/msg00045.html>. * doc/autoconf.texi (Header Templates, Default Includes): (Particular Functions, Generic Functions, Header Portability): (Particular Headers, Generic Headers, Generic Declarations, Guidelines): (Obsolete Macros, AC_FOO_IFELSE vs AC_TRY_FOO): (Present But Cannot Be Compiled, Preprocessor Symbol Index): Prefer #ifdef to #if. * lib/autoconf/c.m4 (AC_C_BIGENDIAN): Prefer #ifdef to #if. * lib/autoconf/functions.m4 (AC_FUNC_ALLOCA, _AC_FUNC_MALLOC_IF): (AC_FUNC_MKTIME, AC_FUNC_MMAP, _AC_FUNC_REALLOC_IF): (AC_FUNC_SELECT_ARGTYPES, AC_FUNC_SETVBUF_REVERSED, _AC_FUNC_VFORK): Likewise. * lib/autoconf/headers.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS): (AC_HEADER_RESOLV, AC_HEADER_STAT): Likewise. * lib/autoconf/specific.m4 (AC_DECL_SYS_SYGLIST): (AC_SYS_RESTARTABLE_SYSCALLS): Likewise. * lib/autoconf/headers.m4 (AC_HEADER_STAT): Don't assume that S_ISDIR etc. are valid for use in #if; POSIX doesn't guarantee this. Index: NEWS =================================================================== RCS file: /cvsroot/autoconf/autoconf/NEWS,v retrieving revision 1.392 diff -p -u -r1.392 NEWS --- NEWS 17 Jul 2006 17:30:44 -0000 1.392 +++ NEWS 15 Aug 2006 16:23:06 -0000 @@ -3,6 +3,9 @@ ** GNU M4 1.4.5 or later is now recommended. At least one "make check" test fails with earlier versions of M4. +** Autoconf now uses constructs like "#ifdef HAVE_STDLIB_H" rather than + "#if HAVE_STDLIB_H", so that it now works with "gcc -Wundef -Werror". + ** The functionality of the undocumented _AC_COMPUTE_INT is now provided by a public and documented macro, AC_COMPUTE_INT. The parameters to the two macros are different, so autoupdate will not change the old private name Index: doc/autoconf.texi =================================================================== RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v retrieving revision 1.1068 diff -p -u -r1.1068 autoconf.texi --- doc/autoconf.texi 14 Aug 2006 22:56:17 -0000 1.1068 +++ doc/autoconf.texi 15 Aug 2006 16:23:07 -0000 @@ -3007,7 +3007,7 @@ then decode the configuration header usi @group #include <conf.h> -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #else /* We are in trouble. */ @@ -3508,11 +3508,11 @@ protected includes, such as: @example @group -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> @@ -3536,36 +3536,36 @@ Expand to @var{include-directives} if de @example @group #include <stdio.h> -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include <memory.h> # endif # include <string.h> #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include <strings.h> #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif -#if HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include <stdint.h> #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #endif @end group @@ -4346,7 +4346,7 @@ like the following, to declare it proper @example @group -#if HAVE_ALLOCA_H +#ifdef HAVE_ALLOCA_H # include <alloca.h> #elif defined __GNUC__ # define alloca __builtin_alloca @@ -4455,7 +4455,7 @@ previous versions of @command{autoconf} yourself in new code: @example @group -#if !HAVE_WORKING_VFORK +#ifndef HAVE_WORKING_VFORK # define vfork fork #endif @end group @@ -4567,7 +4567,7 @@ systems, you must pass 0 to @code{getpgr behaves like Posix's @code{getpgid}. @example -#if GETPGRP_VOID +#ifdef GETPGRP_VOID pid = getpgrp (); #else pid = getpgrp (0); @@ -4617,7 +4617,7 @@ Typically, the replacement file @file{ma the @samp{#undef malloc}): @verbatim -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H # include <config.h> #endif #undef malloc @@ -5024,7 +5024,7 @@ a convenient shorthand. @ovindex LIBOBJS Like @code{AC_CHECK_FUNCS}, but uses @samp{AC_LIBOBJ(@var{function})} as @var{action-if-not-found}. You can declare your replacement function by -enclosing the prototype in @samp{#if !HAVE_@var{function}}. If the +enclosing the prototype in @samp{#ifndef HAVE_@var{function}}. If the system has the function, it probably declares it in a header file you should be including, so you shouldn't redeclare it lest your declaration conflict. @@ -5089,15 +5089,15 @@ beforehand. One should run: AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([net/if.h], [], [], [#include <stdio.h> -#if STDC_HEADERS +#ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif -#if HAVE_SYS_SOCKET_H +#ifdef HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif ]) @@ -5112,15 +5112,15 @@ On Darwin, this file requires that @file AC_CHECK_HEADERS([sys/socket.h]) AC_CHECK_HEADERS([netinet/if_ether.h], [], [], [#include <stdio.h> -#if STDC_HEADERS +#ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif -#if HAVE_SYS_SOCKET_H +#ifdef HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif ]) @@ -5210,13 +5210,13 @@ something like the following: #else # define dirent direct # define NAMLEN(dirent) ((dirent)->d_namlen) -# if HAVE_SYS_NDIR_H +# ifdef HAVE_SYS_NDIR_H # include <sys/ndir.h> # endif -# if HAVE_SYS_DIR_H +# ifdef HAVE_SYS_DIR_H # include <sys/dir.h> # endif -# if HAVE_NDIR_H +# ifdef HAVE_NDIR_H # include <ndir.h> # endif #endif @@ -5258,7 +5258,7 @@ To properly use @file{resolv.h}, your co the following: @verbatim -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_NETINET_IN_H @@ -5299,10 +5299,10 @@ If @file{stdbool.h} exists and conforms @file{system.h} could contain the following code: @verbatim -#if HAVE_STDBOOL_H +#ifdef HAVE_STDBOOL_H # include <stdbool.h> #else -# if ! HAVE__BOOL +# ifndef HAVE__BOOL # ifdef __cplusplus typedef bool _Bool; # else @@ -5383,15 +5383,15 @@ then, in your code, you can use declarat @group /* This example is obsolescent. Nowadays you can just #include <string.h>. */ -#if STDC_HEADERS +#ifdef STDC_HEADERS # include <string.h> #else -# if !HAVE_STRCHR +# ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif char *strchr (), *strrchr (); -# if !HAVE_MEMCPY +# ifndef HAVE_MEMCPY # define memcpy(d, s, n) bcopy ((s), (d), (n)) # define memmove(d, s, n) bcopy ((s), (d), (n)) # endif @@ -5425,7 +5425,7 @@ example: @example @group #include <sys/types.h> -#if HAVE_SYS_WAIT_H +#ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif #ifndef WEXITSTATUS @@ -5453,7 +5453,7 @@ The way to check whether the system supp @example @group -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <sys/types.h> # include <unistd.h> #endif @@ -5481,11 +5481,11 @@ example, @code{struct timeval} as well a @example @group -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> @@ -5514,11 +5514,11 @@ Use: @example @group -#if HAVE_TERMIOS_H +#ifdef HAVE_TERMIOS_H # include <termios.h> #endif -#if GWINSZ_IN_SYS_IOCTL +#ifdef GWINSZ_IN_SYS_IOCTL # include <sys/ioctl.h> #endif @end group @@ -5578,7 +5578,7 @@ scheme: @verbatim AC_CHECK_HEADERS([foo.h]) AC_CHECK_HEADERS([bar.h], [], [], -[#if HAVE_FOO_H +[#ifdef HAVE_FOO_H # include <foo.h> # endif ]) @@ -5659,7 +5659,7 @@ Unlike the other @samp{AC_CHECK_*S} macr declared, @code{HAVE_DECL_@var{symbol}} is defined to @samp{0} instead of leaving @code{HAVE_DECL_@var{symbol}} undeclared. When you are @emph{sure} that the check was performed, use -@code{HAVE_DECL_@var{symbol}} just like any other result of Autoconf: +@code{HAVE_DECL_@var{symbol}} in @code{#if}: @example #if !HAVE_DECL_SYMBOL @@ -7567,12 +7567,18 @@ example, if you call @code{AC_HEADER_STD @example @group -#if HAVE_STDBOOL_H +#ifdef HAVE_STDBOOL_H # include <stdbool.h> #endif @end group @end example +Both @code{#if HAVE_STDBOOL_H} and @code{#ifdef HAVE_STDBOOL_H} will +work with any standard C compiler. Some developers prefer @code{#if} +because it is easier to read, while others prefer @code{#ifdef} because +it avoids diagnostics with picky compilers like @acronym{GCC} with the +@option{-Wundef} option. + If a test program needs to use or create a data file, give it a name that starts with @file{conftest}, such as @file{conftest.data}. The @command{configure} script cleans up by running @samp{rm -f -r conftest*} @@ -16315,7 +16321,7 @@ equivalent modern code (see above), or b @code{AC_CHECK_TYPES} together with @example -#if !HAVE_LOFF_T +#ifndef HAVE_LOFF_T typedef loff_t off_t; #endif @end example @@ -16377,7 +16383,7 @@ Same as: AC_CHECK_DECLS([sys_siglist], [], [], [#include <signal.h> /* NetBSD declares sys_siglist in unistd.h. */ -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #endif ]) @@ -17671,7 +17677,7 @@ The above example, properly written woul @example @group AC_COMPILE_IFELSE([AC_LANG_PROGRAM( -[[#if !defined _AIX +[[#ifndef _AIX error: This isn't AIX! #endif ]])], @@ -18643,7 +18649,7 @@ The proper way the handle this case is u $ @kbd{cat configure.ac} AC_INIT([Example], [1.0], [bug-example@@example.org]) AC_CHECK_HEADERS([number.h pi.h], [], [], -[[#if HAVE_NUMBER_H +[[#ifdef HAVE_NUMBER_H # include <number.h> #endif ]]) @@ -18921,7 +18927,7 @@ on how this is done. This is an alphabetical list of the C preprocessor symbols that the Autoconf macros define. To work with Autoconf, C source code needs to -use these names in @code{#if} directives. +use these names in @code{#if} or @code{#ifdef} directives. @printindex cv Index: lib/autoconf/c.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v retrieving revision 1.231 diff -p -u -r1.231 c.m4 --- lib/autoconf/c.m4 22 Jun 2006 23:50:07 -0000 1.231 +++ lib/autoconf/c.m4 15 Aug 2006 16:23:07 -0000 @@ -1316,7 +1316,8 @@ AC_DEFUN([AC_C_BIGENDIAN], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h> #include <sys/param.h> ], -[#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN +[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) bogus endian macros #endif ])], Index: lib/autoconf/functions.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v retrieving revision 1.106 diff -p -u -r1.106 functions.m4 --- lib/autoconf/functions.m4 23 Jun 2006 15:18:45 -0000 1.106 +++ lib/autoconf/functions.m4 15 Aug 2006 16:23:07 -0000 @@ -370,7 +370,7 @@ AC_CACHE_CHECK([for alloca], ac_cv_func_ # include <malloc.h> # define alloca _alloca # else -# if HAVE_ALLOCA_H +# ifdef HAVE_ALLOCA_H # include <alloca.h> # else # ifdef _AIX @@ -875,7 +875,7 @@ AC_CHECK_HEADERS(stdlib.h) AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull, [AC_RUN_IFELSE( [AC_LANG_PROGRAM( -[[#if STDC_HEADERS || HAVE_STDLIB_H +[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include <stdlib.h> #else char *malloc (); @@ -977,26 +977,26 @@ AC_CHECK_FUNCS(alarm) AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime, [AC_RUN_IFELSE([AC_LANG_SOURCE( [[/* Test program from Paul Eggert and Tony Leneis. */ -#if TIME_WITH_SYS_TIME +#ifdef TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else -# if HAVE_SYS_TIME_H +# ifdef HAVE_SYS_TIME_H # include <sys/time.h> # else # include <time.h> # endif #endif -#if HAVE_STDLIB_H +#ifdef HAVE_STDLIB_H # include <stdlib.h> #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #endif -#if !HAVE_ALARM +#ifndef HAVE_ALARM # define alarm(X) /* empty */ #endif @@ -1186,21 +1186,21 @@ AC_CACHE_CHECK(for working mmap, ac_cv_f #include <fcntl.h> #include <sys/mman.h> -#if !STDC_HEADERS && !HAVE_STDLIB_H +#if !defined STDC_HEADERS && !defined HAVE_STDLIB_H char *malloc (); #endif /* This mess was copied from the GNU getpagesize.h. */ -#if !HAVE_GETPAGESIZE +#ifndef HAVE_GETPAGESIZE /* Assume that all systems that can run configure have sys/param.h. */ -# if !HAVE_SYS_PARAM_H +# ifndef HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 # endif # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ -# if HAVE_SYS_PARAM_H +# ifdef HAVE_SYS_PARAM_H # include <sys/param.h> # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE @@ -1335,7 +1335,7 @@ AC_CHECK_HEADERS(stdlib.h) AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull, [AC_RUN_IFELSE( [AC_LANG_PROGRAM( -[[#if STDC_HEADERS || HAVE_STDLIB_H +[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H # include <stdlib.h> #else char *realloc (); @@ -1382,10 +1382,10 @@ AC_CACHE_CHECK([types of arguments for s AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [AC_INCLUDES_DEFAULT -#if HAVE_SYS_SELECT_H +#ifdef HAVE_SYS_SELECT_H # include <sys/select.h> #endif -#if HAVE_SYS_SOCKET_H +#ifdef HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif ], @@ -1655,14 +1655,14 @@ AC_CACHE_CHECK(whether setvbuf arguments AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <stdio.h> -# if PROTOTYPES +# ifdef PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif]], [[char buf; return setvbuf (stdout, _IOLBF, &buf, 1);]])], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include <stdio.h> -# if PROTOTYPES +# ifdef PROTOTYPES int (setvbuf) (FILE *, int, char *, size_t); # endif]], [[char buf; return setvbuf (stdout, &buf, _IOLBF, 1);]])], @@ -1822,7 +1822,7 @@ AC_DEFUN([_AC_FUNC_VFORK], [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */ ]AC_INCLUDES_DEFAULT[ #include <sys/wait.h> -#if HAVE_VFORK_H +#ifdef HAVE_VFORK_H # include <vfork.h> #endif /* On some sparc systems, changes by the child to local and incoming Index: lib/autoconf/headers.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v retrieving revision 1.50 diff -p -u -r1.50 headers.m4 --- lib/autoconf/headers.m4 15 May 2006 02:22:28 -0000 1.50 +++ lib/autoconf/headers.m4 15 Aug 2006 16:23:07 -0000 @@ -243,36 +243,36 @@ AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREME dnl If ever you change this variable, please keep autoconf.texi in sync. ac_includes_default="\ #include <stdio.h> -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include <stdlib.h> # include <stddef.h> #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include <stdlib.h> # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include <memory.h> # endif # include <string.h> #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include <strings.h> #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include <inttypes.h> #endif -#if HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include <stdint.h> #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #endif" ])dnl @@ -483,7 +483,7 @@ AN_HEADER(resolv.h, [AC_HEADER_RESOLV]) AC_DEFUN([AC_HEADER_RESOLV], [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h, [], [], -[[#if HAVE_SYS_TYPES_H +[[#ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_NETINET_IN_H @@ -511,33 +511,25 @@ AN_IDENTIFIER([S_ISSOCK], [AC_HEADER_STA AC_DEFUN([AC_HEADER_STAT], [AC_CACHE_CHECK(whether stat file-mode macros are broken, ac_cv_header_stat_broken, -[AC_EGREP_CPP([You lose], [#include <sys/types.h> +[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h> #include <sys/stat.h> #if defined S_ISBLK && defined S_IFDIR -# if S_ISBLK (S_IFDIR) -You lose. -# endif +extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1]; #endif #if defined S_ISBLK && defined S_IFCHR -# if S_ISBLK (S_IFCHR) -You lose. -# endif +extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1]; #endif #if defined S_ISLNK && defined S_IFREG -# if S_ISLNK (S_IFREG) -You lose. -# endif +extern char c3[S_ISLNK (S_IFREG) ? -1 : 1]; #endif #if defined S_ISSOCK && defined S_IFREG -# if S_ISSOCK (S_IFREG) -You lose. -# endif +extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1]; #endif -], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)]) +]])], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)]) if test $ac_cv_header_stat_broken = yes; then AC_DEFINE(STAT_MACROS_BROKEN, 1, [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not Index: lib/autoconf/specific.m4 =================================================================== RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v retrieving revision 1.369 diff -p -u -r1.369 specific.m4 --- lib/autoconf/specific.m4 7 Aug 2006 07:10:25 -0000 1.369 +++ lib/autoconf/specific.m4 15 Aug 2006 16:23:07 -0000 @@ -63,7 +63,7 @@ AU_DEFUN([AC_DECL_SYS_SIGLIST], [AC_CHECK_DECLS([sys_siglist],,, [#include <signal.h> /* NetBSD declares sys_siglist in unistd.h. */ -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include <unistd.h> #endif ]) @@ -256,7 +256,7 @@ AC_CACHE_CHECK(for restartable system ca AC_INCLUDES_DEFAULT #include <signal.h> -#if HAVE_SYS_WAIT_H +#ifdef HAVE_SYS_WAIT_H # include <sys/wait.h> #endif _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf