From: Zack Weinberg Date: Mon, 7 Dec 2020 16:49:52 +0000 (-0500) Subject: Add checks of __STDC__ and __STDC_VERSION__ to C conformance tests. X-Git-Tag: v2.70~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d132ea0278f574fbb3c8d433ea094e36ece73ba1;p=thirdparty%2Fautoconf.git Add checks of __STDC__ and __STDC_VERSION__ to C conformance tests. This makes the C conformance tests more consistent with the C++ conformance tests, and should also speed up cycling through the possible options to turn on C99/C11. Tested with gcc, clang, SunPRO C, and AIX xlc. * lib/autoconf/c.m4 (_AC_C_C89_TEST_GLOBALS): Add preprocessor test for __STDC__ being defined (to any value). (_AC_C_C99_TEST_GLOBALS, _AC_C_C11_TEST_GLOBALS): Add preprocessor test of the value of __STDC_VERSION__. --- diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index d4bed687..7984f25f 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -1143,6 +1143,13 @@ AC_DEFUN([_AC_C_C89_TEST_GLOBALS], [m4_divert_text([INIT_PREPARE], [[# Test code for whether the C compiler supports C89 (global declarations) ac_c_conftest_c89_globals=' +/* Does the compiler advertise C89 conformance? + Do not test the value of __STDC__, because some compilers set it to 0 + while being otherwise adequately conformant. */ +#if !defined __STDC__ +# error "Compiler does not advertise C89 conformance" +#endif + #include #include struct stat; @@ -1198,6 +1205,11 @@ AC_DEFUN([_AC_C_C99_TEST_GLOBALS], [m4_divert_text([INIT_PREPARE], [[# Test code for whether the C compiler supports C99 (global declarations) ac_c_conftest_c99_globals=' +// Does the compiler advertise C99 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L +# error "Compiler does not advertise C99 conformance" +#endif + #include extern int puts (const char *); extern int printf (const char *, ...); @@ -1345,6 +1357,11 @@ AC_DEFUN([_AC_C_C11_TEST_GLOBALS], [m4_divert_text([INIT_PREPARE], [[# Test code for whether the C compiler supports C11 (global declarations) ac_c_conftest_c11_globals=' +// Does the compiler advertise C11 conformance? +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L +# error "Compiler does not advertise C11 conformance" +#endif + // Check _Alignas. char _Alignas (double) aligned_as_double; char _Alignas (0) no_special_alignment;