autoconf-patches
[Top][All Lists]
Advanced

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

Re: fix AC_C_CONST to work with CFLAGS -O2 -Wall -Werror


From: Eric Blake
Subject: Re: fix AC_C_CONST to work with CFLAGS -O2 -Wall -Werror
Date: Sat, 10 May 2008 10:12:02 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Didier Barvaux on 5/10/2008 9:37 AM:
| Hi all,
|
| I seems that GCC fails to compile the code generated by the AC_C_CONST
| macro if the -O2 -Wall -Werror CFLAGS are specified.

Thanks for the report.  AC_C_CONST is obsolete - as of autoconf 2.60,
there were no known compilers on typical porting platforms that lacked
const support.  The easier fix is just to delete that macro from gcc's
configure.ac, and require C89 support from the system compiler.  And
trying to bootstrap a package with -Werror is so prone to failure that in
general, we don't guarantee that is possible (even though some packages go
out of their way to try to support it).

|
| Below is a patch that corrects the problem with AC_C_CONST. This patch
| works great on my system. It may perhaps break the macro on other
| systems, I don't know.
|
|  #ifndef __cplusplus
|    /* Ultrix mips cc rejects this.  */
|    typedef int charset[2];
| -  const charset cs;
| +  const charset cs = { 0, 0 };

Changing this looks fishy.

| @@ -1605,10 +1605,7 @@ AC_DEFUN([AC_C_CONST],
|    ppc = (char**) pcpcc;
|    pcpcc = (char const *const *) ppc;
|    { /* SCO 3.2v4 cc rejects this.  */
| -    char *t;
|      char const *s = 0 ? (char *) 0 : (char const *) 0;
| -
| -    *t++ = 0;
|      if (s) return 0;

Seems reasonable.

| @@ -1624,7 +1621,9 @@ AC_DEFUN([AC_C_CONST],
|    { /* AIX XL C 1.02.0.0 rejects this saying
|         "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable
lvalue. */
|      struct s { int j; const int *ap[3]; };
| -    struct s *b; b->j = 5;
| +    struct s a;
| +    struct s *b = &a;
| +    b->j = 5;
|    }

Also seems reasonable.

|
| Any comments are welcome.

I'd like to hear from at least Paul Eggert before applying (part or all
of) this, as he has more experience with AC_C_CONST.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkglyVEACgkQ84KuGfSFAYD8dwCZAVF4pR8i1MNzf2hKaj3s0Tl2
apgAn1Im7ycQZA0Ycsr6ufHztPzAA+6d
=up+P
-----END PGP SIGNATURE-----




reply via email to

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