summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2023-04-02 21:54:31 -0400
committerZack Weinberg <zackw@panix.com>2023-04-02 23:01:50 -0400
commita7dc6d83c7d12b8409c512c3c10ad29f01e6c164 (patch)
tree38cd1f6dd93d52b53dd2a1433e36b067ef1f5e16
parentb5891a57b586ef6ff78bb752d62915b78cd58d7e (diff)
downloadautoconf-a7dc6d83c7d12b8409c512c3c10ad29f01e6c164.tar.gz
Fold AC_C_STRINGIZE into AC_PROG_CC.
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.
-rw-r--r--lib/autoconf/c.m431
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 33648b5b..c8c6a665 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -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