-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul Eggert <[EMAIL PROTECTED]> writes:
> Roger Leigh <[EMAIL PROTECTED]> writes:
>
>> One change I've made is added arguments to AC_PROG_CC_C89,
>> AC_PROG_CC_C89 and AC_PROG_CC_STDC to allow custom code to run on
>> success or failure, to e.g. abort configure if there isn't a C99
>> compiler available.
>
> I'd rather avoid this complexity. Isn't it easy enough to abort based
> on the value of ac_cv_prog_cc_c89 (or whatever)?
Yes, but I didn't know if users were allowed access to those
internals. I've reverted this (but kept it for internal use).
> Can you please also check for the following features?
>
> variable declarations in for loops
> last member of a struct may be an incomplete array type
> varargs macros
> named initialization of structs
> variable length arrays
> long long
>
> These are all features that C99-ish programs are likely to want.
>
>> +# AC_PROG_CC_STDC ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
>> +# ----------------------------------------------------------------
>> +AC_DEFUN([AC_PROG_CC_STDC],
>> +[AC_PROG_CC_C99([$1], [$2])])
>
> This isn't quite right. It should try for C99 mode, and failing that
> it should try for C89 mode.
I've made the above changes, additions and updates NEWS and
autoconf.texi. A diff against the current CVS is attached.
Regards,
Roger
- --
Roger Leigh
Printing on GNU/Linux? http://gimp-print.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 <http://mailcrypt.sourceforge.net/>
iD8DBQFBrz2KVcFcaSW/uEgRAqTIAJoC7gAtOqwJ41oSkPMx8ePMzFW90gCfQUJe
FywvxT3sK1EVGjTyRM6837U=
=l2Te
-----END PGP SIGNATURE-----
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.332
diff -u -r1.332 NEWS
--- NEWS 29 Nov 2004 21:24:57 -0000 1.332
+++ NEWS 2 Dec 2004 16:06:22 -0000
@@ -1,3 +1,14 @@
+* Major changes in Autoconf 2.59c
+
+** AC_PROG_CC_C89, AC_PROG_CC_C99
+ New macros for ISO C99 support. _AC_PROG_CC_STDC has been renamed
+ to AC_PROG_CC_C89. The shell variable ac_cv_prog_cc_stdc has been
+ renamed to ac_cv_prog_cc_c89 to reflect its more precise role.
+
+** AC_PROG_CC_STDC
+ Has been unobsoleted, and will check if the compiler supports ISO
+ C99, falling back to ANSI C89 if not.
+
* Major changes in Autoconf 2.59b
Released 2004-08-20, by Paul Eggert.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.846
diff -u -r1.846 autoconf.texi
--- doc/autoconf.texi 29 Nov 2004 21:43:11 -0000 1.846
+++ doc/autoconf.texi 2 Dec 2004 16:06:41 -0000
@@ -5572,7 +5572,7 @@
After calling this macro you can check whether the C compiler has been
set to accept @acronym{ANSI} C; if not, the shell variable
[EMAIL PROTECTED] is set to @samp{no}. If you wrote your source
[EMAIL PROTECTED] is set to @samp{no}. If you wrote your source
code in @acronym{ANSI} C, you can make an [EMAIL PROTECTED] copy of it by
using the program @code{ansi2knr}, which comes with Automake. See also
under @code{AC_C_PROTOTYPES} below.
@@ -5626,6 +5626,36 @@
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or
@code{AC_RUN_IFELSE} (@pxref{Run Time}).
[EMAIL PROTECTED] AC_PROG_CC_STDC
[EMAIL PROTECTED]
+If the C compiler is not able to compile ISO Standard C (currently ISO
+C99), try to add an option to output variable @code{CC} to make it so.
+If the compiler does not support ISO C99, fall back to supporting ANSI
+C89 (ISO C90).
[EMAIL PROTECTED] defmac
+
[EMAIL PROTECTED] AC_PROG_CC_C89
[EMAIL PROTECTED]
+If the C compiler is not in ANSI C89 (ISO C90) mode by default, try to
+add an option to output variable @code{CC} to make it so. This macro
+tries various options that select ANSI C89 on some system or another.
+It considers the compiler to be in ANSI C89 mode if it handles function
+prototypes correctly.
+
+This macro is called automatically by @code{AC_PROG_CC}.
[EMAIL PROTECTED] defmac
+
[EMAIL PROTECTED] AC_PROG_CC_C99
[EMAIL PROTECTED]
+If the C compiler is not in ISO C99 C mode by default, try to add an
+option to output variable @code{CC} to make it so. This macro tries
+various options that select ISO C99 C on some system or another. It
+considers the compiler to be in ISO C99 C mode if it handles _Bool,
+flexible arrays, inline, long long, mixed code and declarations, named
+initialization of structs, restrict, varargs macros, variable
+declarations in for loops and variable length arrays.
[EMAIL PROTECTED] defmac
+
@defmac AC_C_BACKSLASH_A
@acindex{HAVE_C_BACKSLASH_A}
Define @samp{HAVE_C_BACKSLASH_A} to 1 if the C compiler understands
@@ -14204,11 +14234,6 @@
@code{AC_PREFIX_PROGRAM}
@end defmac
[EMAIL PROTECTED] AC_PROG_CC_STDC
[EMAIL PROTECTED]
-This macro has been integrated into @code{AC_PROG_CC}.
[EMAIL PROTECTED] defmac
-
@defmac AC_PROGRAMS_CHECK
@acindex{PROGRAMS_CHECK}
@code{AC_CHECK_PROGS}
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.190
diff -u -r1.190 c.m4
--- lib/autoconf/c.m4 20 Aug 2004 07:01:02 -0000 1.190
+++ lib/autoconf/c.m4 2 Dec 2004 16:06:42 -0000
@@ -485,7 +485,7 @@
_AC_LANG_COMPILER_GNU
GCC=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_CC_G
-_AC_PROG_CC_STDC
+_AC_PROG_CC_C89
# Some people use a C++ compiler to compile C. Since we use `exit',
# in C++ we need to declare it. In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
@@ -810,17 +810,17 @@
# 4b. C compiler characteristics. #
# -------------------------------- #
-# _AC_PROG_CC_STDC
-# ----------------
-# If the C compiler in not in ANSI C mode by default, try to add an
-# option to output variable @code{CC} to make it so. This macro tries
-# various options that select ANSI C on some system or another. It
-# considers the compiler to be in ANSI C mode if it handles function
-# prototypes correctly.
-AC_DEFUN([_AC_PROG_CC_STDC],
-[AC_MSG_CHECKING([for $CC option to accept ANSI C])
-AC_CACHE_VAL(ac_cv_prog_cc_stdc,
-[ac_cv_prog_cc_stdc=no
+# _AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
+# ----------------------------------------------------------------
+# If the C compiler is not in ANSI C89 (ISO C90) mode by default, try
+# to add an option to output variable @code{CC} to make it so. This
+# macro tries various options that select ANSI C89 on some system or
+# another. It considers the compiler to be in ANSI C89 mode if it
+# handles function prototypes correctly.
+AC_DEFUN([_AC_PROG_CC_C89],
+[AC_MSG_CHECKING([for $CC option to accept ANSI C89 C])
+AC_CACHE_VAL(ac_cv_prog_cc_c89,
+[ac_cv_prog_cc_c89=no
ac_save_CC=$CC
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <stdarg.h>
@@ -873,26 +873,197 @@
do
CC="$ac_save_CC $ac_arg"
_AC_COMPILE_IFELSE([],
- [ac_cv_prog_cc_stdc=$ac_arg
+ [ac_cv_prog_cc_c89=$ac_arg
+break])
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+if test "x$ac_cv_prog_cc_c89" = x; then
+ CC="$ac_save_CC"
+else
+ CC="$ac_save_CC $ac_cv_prog_cc_c89"
+fi
+])
+case "x$ac_cv_prog_cc_c89" in
+ xno)
+ AC_MSG_RESULT([unsupported])
+ $2 ;;
+ *)
+ if test "x$ac_cv_prog_cc_c89" = x; then
+ AC_MSG_RESULT([none needed])
+ else
+ AC_MSG_RESULT([$ac_cv_prog_cc_c89])
+ fi
+ $1 ;;
+esac
+])# _AC_PROG_CC_C89
+
+
+# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
+# ----------------------------------------------------------------
+# If the C compiler is not in ISO C99 C mode by default, try to add an
+# option to output variable @code{CC} to make it so. This macro tries
+# various options that select ISO C99 C on some system or another. It
+# considers the compiler to be in ISO C99 C mode if it handles mixed
+# code and declarations, _Bool, inline and restrict.
+AC_DEFUN([_AC_PROG_CC_C99],
+[AC_MSG_CHECKING([for $CC option to accept ISO C99 C])
+AC_CACHE_VAL(ac_cv_prog_cc_c99,
+[ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+AC_LANG_CONFTEST([AC_LANG_PROGRAM(
+[[#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
+
+struct incomplete_array
+{
+ int datasize;
+ double data[];
+};
+
+struct named_init {
+ int number;
+ const wchar_t *name;
+ double average;
+};
+
+static inline int
+test_restrict(const char *restrict text)
+{
+ // See if C++-style comments work.
+ // Iterate through items via the restricted pointer.
+ // Also check for declarations in for loops.
+ for (unsigned int i = 0; *(text+i) != '\0'; ++i);
+ return 0;
+}
+
+// Check varargs and va_copy work.
+static void
+test_varargs(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ va_list args_copy;
+ va_copy(args_copy, args);
+
+ const char *str;
+ int number;
+ float fnumber;
+
+ while (*format)
+ {
+ switch (*format++)
+ {
+ case 's': // string
+ str = va_arg(args_copy, const char *);
+ break;
+ case 'd': // int
+ number = va_arg(args_copy, int);
+ break;
+ case 'f': // float
+ fnumber = (float) va_arg(args_copy, double);
+ break;
+ default:
+ break;
+ }
+ }
+ va_end(args_copy);
+ va_end(args);
+}
+]],
+[[
+ // Check bool and long long datatypes.
+ _Bool success = false;
+ long long int bignum = -1234567890LL;
+ unsigned long long int ubignum = 1234567890uLL;
+
+ // Check restrict.
+ if (test_restrict("String literal") != 0)
+ success = true;
+ char *restrict newvar = "Another string";
+
+ // Check varargs.
+ test_varargs("s, d' f .", "string", 65, 34.234);
+
+ // Check incomplete arrays work.
+ struct incomplete_array *ia =
+ malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10));
+ ia->datasize = 10;
+ for (int i = 0; i < ia->datasize; ++i)
+ ia->data[i] = (double) i * 1.234;
+
+ // Check named initialisers.
+ struct named_init ni = {
+ .number = 34,
+ .name = L"Test wide string",
+ .average = 543.34343,
+ };
+
+ ni.number = 58;
+
+ int dynamic_array[ni.number];
+ dynamic_array[43] = 543;
+]])])
+# Try
+# GCC -std=gnu99 -std=c99 -std=iso9899:1999
+# AIX -qlanglvl=extc99 -qlanglvl=stdc99
+# Intel ICC -c99
+# IRIX -c99
+# Solaris -xc99
+# Tru64 -c99
+for ac_arg in "" -std=gnu99 -std=c99 -std=iso9899:1999 -c99 -xc99 -qlanglvl=extc99 -qlanglvl=stdc99
+do
+ CC="$ac_save_CC $ac_arg"
+ _AC_COMPILE_IFELSE([],
+ [ac_cv_prog_cc_c99=$ac_arg
break])
done
rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
+if test "x$ac_cv_prog_cc_c99" = x; then
+ CC="$ac_save_CC"
+else
+ CC="$ac_save_CC $ac_cv_prog_cc_c99"
+fi
])
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- AC_MSG_RESULT([none needed]) ;;
+case "x$ac_cv_prog_cc_c99" in
+ xno)
+ AC_MSG_RESULT([unsupported])
+ $2 ;;
*)
- AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
- CC="$CC $ac_cv_prog_cc_stdc" ;;
+ if test "x$ac_cv_prog_cc_c99" = x; then
+ AC_MSG_RESULT([none needed])
+ else
+ AC_MSG_RESULT([$ac_cv_prog_cc_c99])
+ fi
+ $1 ;;
esac
-])# _AC_PROG_CC_STDC
+])# _AC_PROG_CC_C99
+
+
+# AC_PROG_CC_C89
+# --------------
+AC_DEFUN([AC_PROG_CC_C89],
+[ AC_REQUIRE([AC_PROG_CC])dnl
+ _AC_PROG_CC_C89
+])
+
+
+# AC_PROG_CC_C99
+# --------------
+AC_DEFUN([AC_PROG_CC_C99],
+[ AC_REQUIRE([AC_PROG_CC])dnl
+ _AC_PROG_CC_C99
+])
# AC_PROG_CC_STDC
# ---------------
-# Has been merged into AC_PROG_CC.
-AU_DEFUN([AC_PROG_CC_STDC], [])
+AC_DEFUN([AC_PROG_CC_STDC],
+[ AC_REQUIRE([AC_PROG_CC])dnl
+ _AC_PROG_CC_C99(, [_AC_PROG_CC_C89])dnl
+])
# AC_C_BACKSLASH_A
@@ -1244,7 +1415,7 @@
AC_DEFUN([AC_C_PROTOTYPES],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_MSG_CHECKING([for function prototypes])
-if test "$ac_cv_prog_cc_stdc" != no; then
+if test "$ac_cv_prog_cc_c89" != no; then
AC_MSG_RESULT([yes])
AC_DEFINE(PROTOTYPES, 1,
[Define to 1 if the C compiler supports function prototypes.])
_______________________________________________
Autoconf mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/autoconf