[Top][All Lists]

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


From: Bruno Haible
Date: Mon, 14 May 2007 00:55:36 +0200
User-agent: KMail/1.5.4


The NEWS of autoconf 2.60 has this:

    Has been unobsoleted, and will check if the compiler supports ISO
    C99, falling back to ANSI C89 if not.

This leads to a problem: AC_C_RESTRICT, AC_PROG_CC_STDC, and mixed C/C++
are incompatible.

In detail:

My package consists of mixed C and C++ source code. It uses a single config.h
for both parts (please don't recommend two different config.h's, one for C and
one for C++ - that would be an unacceptable complexity).

The package uses 'restrict' like this:
  extern char *stpcpy (char *restrict dst, char const *restrict src);
and therefore invokes AC_C_RESTRICT.

The package also uses the gnulib module 'stdarg', which contains the following
  dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode
  dnl for the builtin va_copy to work.  With Autoconf 2.60 or later,
  dnl AC_PROG_CC_STDC arranges for this.  With older Autoconf AC_PROG_CC_STDC
  dnl shouldn't hurt, though installers are on their own to set c99 mode.

I try to compile it on mingw, where the C compiler is gcc version 3.4.2 and
the C++ compiler is g++ version 3.4.2.

At configuration time, 'configure' runs AC_PROG_CC_STDC first, then
AC_C_RESTRICT. During the AC_PROG_CC_STDC run, it changes the CC variable
from "gcc" to "gcc -std=gnu99". The AC_C_RESTRICT test is run with this
compiler, detecting that the C compiler supports 'restrict'. config.h then
contains this:
  /* #undef restrict */

At "make" time, the compilation of the C++ parts of the package fails with
a syntax error.

The support of 'restrict' and '__restrict' is this:

                |  restrict    |   __restrict
gcc             |    no        |       yes
gcc -std=gnu99  |    yes       |       yes
g++             |    no        |       yes

Should I work around this in my package? I'd say no, because the use of
AC_C_RESTRICT, AC_PROG_CC_STDC, and C++ are widespread elsewhere as well.

Should my package not invoke AC_PROG_CC_STDC? I'd say no, because the C99
mode is needed for AIX and stdarg.

Should my package not invoke AC_C_RESTRICT? Well. What other macro does
autoconf provide that defines 'restrict' appropriately?

The minimally invasive change is probably that AC_C_RESTRICT defines
'restrict' to '__restrict', if the compiler is gcc >= 2.95, even if
the C compiler also supports 'restrict' natively.


reply via email to

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