AC_PROG_CC([gcc cl cc])
@end example
-If the C compiler cannot compile ISO Standard C (currently
-C11), try to add an option to output variable @code{CC} to make it work.
-If the compiler does not support C11, fall back to supporting
-ISO C99; if C99 does not work, fall back to ANSI C89 (ISO C90).
-When testing for ISO C versions, use GNU extensions if available.
+If necessary, add an option to output variable @code{CC} to enable
+support for ISO Standard C features with extensions. Prefer the newest
+C standard that is supported. Currently the newest standard is ISO C11,
+with ISO C99 and ANSI C89 (ISO C90) being the older versions.
After calling this macro you can check whether the C compiler has been
set to accept Standard C; if not, the shell variable
@code{ac_cv_prog_cc_stdc} is set to @samp{no}.
When attempting to add compiler options, prefer extended functionality
-modes over strict conformance modes. Test for C11 support by checking
+to strict conformance: the goal is to enable whatever standard features
+that are available, not to check for full conformance to the standard or
+to prohibit incompatible extensions. Test for C11 support by checking
for @code{_Alignas}, @code{_Alignof}, @code{_Noreturn},
@code{_Static_assert}, UTF-8 string literals, duplicate @code{typedef}s,
and anonymous structures and unions. Test for C99 support by checking
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking how to run the C preprocessor... gcc -std=gnu11 -E
OK
@end example
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking how to run the C preprocessor... gcc -std=gnu11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
-checking for gcc option to accept ISO C11... -std=gnu11
+checking for gcc option to enable C11 features... -std=gnu11
checking for number.h... yes
checking for pi.h... yes
@end example
# helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
# else ACTION-IF-UNAVAILABLE.
AC_DEFUN([_AC_C_STD_TRY],
-[AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
+[AC_MSG_CHECKING([for $CC option to enable ]m4_translit($1, [c], [C])[ features])
AC_CACHE_VAL(ac_cv_prog_cc_$1,
[ac_cv_prog_cc_$1=no
ac_save_CC=$CC
[_AC_C_C99_TEST_BODY],
dnl Try
dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
-dnl IBM XL C -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
+dnl IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
+dnl IBM XL C -qlanglvl=extc99
+dnl (pre-V12.1; unused restrictive mode: -qlanglvl=stdc99)
dnl HP cc -AC99
dnl Intel ICC -std=c99, -c99 (deprecated)
dnl IRIX -c99
dnl http://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
dnl Tru64 -c99
dnl with extended modes being tried first.
-[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99]], [$1], [$2])[]dnl
+[[-std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc1x -qlanglvl=extc99]], [$1], [$2])[]dnl
])# _AC_PROG_CC_C99
]],
dnl Try
dnl GCC -std=gnu11 (unused restrictive mode: -std=c11)
-dnl IBM XL C -qlanglvl=extc1x (no extc11 or (unused) stdc11 in V12.1)
dnl with extended modes being tried first.
-[[-std=gnu11 -qlanglvl=extc1x]], [$1], [$2])[]dnl
+dnl
+dnl Do not try -qlanglvl=extc1x, because IBM XL C V12.1 (the latest version as
+dnl of September 2012) does not pass the C11 test. For now, try extc1x when
+dnl compiling the C99 test instead, since it enables _Static_assert and
+dnl _Noreturn, which is a win. If -qlanglvl=extc11 or -qlanglvl=extc1x passes
+dnl the C11 test in some future version of IBM XL C, we'll add it here,
+dnl preferably extc11.
+[[-std=gnu11]], [$1], [$2])[]dnl
])# _AC_PROG_CC_C11