]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fold AC_C_STRINGIZE into AC_PROG_CC.
authorZack Weinberg <zackw@panix.com>
Mon, 3 Apr 2023 01:54:31 +0000 (21:54 -0400)
committerZack Weinberg <zackw@panix.com>
Mon, 3 Apr 2023 03:01:50 +0000 (23:01 -0400)
Another of the last few uses of AC_EGREP_CPP is to check for the ISO C
“stringification” operator.  As this is a feature of C89, let’s fold
the test into the extensive C89 tests we already have, and make
AC_C_STRINGIZE just lean on AC_PROG_CC, in the same way
AC_C_PROTOTYPES does.

* lib/autoconf/c.m4 (_AC_C_C89_TEST_GLOBALS): Add test of preprocessor
  stringification and token pasting.
  (AC_C_STRINGIZE): Just check ac_prog_cc_stdc.

lib/autoconf/c.m4

index 33648b5b9303e17abec308cd364fba42f1e6fafd..c8c6a665c963150d9a4cd5e5d76dd63e234fc89b 100644 (file)
@@ -1143,6 +1143,21 @@ static char *f (char * (*g) (char **, int), char **p, ...)
   return s;
 }
 
+/* C89 style stringification. */
+#define noexpand_stringify(a) #a
+const char *stringified = noexpand_stringify(arbitrary+token=sequence);
+
+/* C89 style token pasting.  Exercises some of the corner cases that
+   e.g. old MSVC gets wrong, but not very hard. */
+#define noexpand_concat(a,b) a##b
+#define expand_concat(a,b) noexpand_concat(a,b)
+extern int vA;
+extern int vbee;
+#define aye A
+#define bee B
+int *pvA = &expand_concat(v,aye);
+int *pvbee = &noexpand_concat(v,bee);
+
 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
    function prototypes and stuff, but not \xHH hex character constants.
    These do not provoke an error unfortunately, instead are silently treated
@@ -2112,16 +2127,10 @@ fi
 # --------------
 # Checks if '#' can be used to glue strings together at the CPP level.
 # Defines HAVE_STRINGIZE if positive.
+# Obsolete - new code should assume C89 compliance.
 AC_DEFUN([AC_C_STRINGIZE],
-[AC_CACHE_CHECK([for preprocessor stringizing operator],
-               [ac_cv_c_stringize],
-[AC_EGREP_CPP([@%:@teststring],
-             [@%:@define x(y) #y
-
-char *s = x(teststring);],
-             [ac_cv_c_stringize=no],
-             [ac_cv_c_stringize=yes])])
-if test $ac_cv_c_stringize = yes; then
+[AC_REQUIRE([AC_PROG_CC])
+if test "$ac_prog_cc_stdc" != no; then
   AC_DEFINE(HAVE_STRINGIZE, 1,
            [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
 fi
@@ -2130,8 +2139,8 @@ fi
 
 # AC_C_PROTOTYPES
 # ---------------
-# Check if the C compiler supports prototypes, included if it needs
-# options.
+# Check if the C compiler supports prototypes.
+# Obsolete - new code should assume C89 compliance.
 AC_DEFUN([AC_C_PROTOTYPES],
 [AC_REQUIRE([AC_PROG_CC])dnl
 if test "$ac_prog_cc_stdc" != no; then