autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_CHECK_SIZEOF failing on undefined HAVE_STDINT_H with -Werror


From: David Fang
Subject: Re: AC_CHECK_SIZEOF failing on undefined HAVE_STDINT_H with -Werror
Date: Tue, 15 Aug 2006 20:15:09 -0400 (EDT)

Thanks to all for the discussion, and to Paul for the swift and decisive
patch.  I do have a few comments about the documentation portion of
the patch.

> 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  <address@hidden>
>
>       * 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.

In practice, I have actually caught one or two serious errors using
-Wundef -Werror, as anal-retentive and controversial as it may seem.
YMMV.

> @@ -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
> address@hidden 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*}

Wasn't it pointed out in this thread (#if vs. #ifdef) that evaluating
an undefined macro with #if is undefined in standard C?  (i.e. cannot
assumed to be equivalent to evaluating 0).  I'm not sure about the claim
that #if HAVE_STDBOOL_H would behave as expected universally in the case
there HAVE_STDBOOL_H is undefined.

Also perhaps it should be noted somewhere that while autoconf's m4 macros
now use #ifdef to conditionally include headers, users may still use
#if USER_DEFINED_MACRO as long as the said macro is defined in all cases
by the configure test.  This internal change doesn't force any users to
define and use configure macros with one convention or the other.  The
important thing is that definition and use are consistent.


Just confirming: will this revision appear in release 2.61?


Fang





reply via email to

[Prev in Thread] Current Thread [Next in Thread]