]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
string-desc: Revisit feature tests regarding C++.
authorBruno Haible <bruno@clisp.org>
Sun, 11 Jan 2026 21:58:14 +0000 (22:58 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Jan 2026 22:00:49 +0000 (23:00 +0100)
* lib/string-desc.h (HAVE_STATEMENT_EXPRESSIONS): Also define with
SunPRO C++.
(HAVE__GENERIC): Don't define with GNU C++. Define in ISO C 11 or newer.

ChangeLog
lib/string-desc.h

index 9fdc1b301dc0392ade50ee02e0cd312b649a040f..d5ca627ee559997193997ccc4fa0539d087ba615 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-01-11  Bruno Haible  <bruno@clisp.org>
+
+       string-desc: Revisit feature tests regarding C++.
+       * lib/string-desc.h (HAVE_STATEMENT_EXPRESSIONS): Also define with
+       SunPRO C++.
+       (HAVE__GENERIC): Don't define with GNU C++. Define in ISO C 11 or newer.
+
 2026-01-10  Pádraig Brady  <P@draigBrady.com>
 
        selinux-h: warning about missing libselinux on modern systems
index db4570695fe9cfb24a8bf5a096362942c7a37d42..4eaafdd95cba14837875cabe79b1a51e21f85960 100644 (file)
    Test program:
      int f (int x) { return ({ x; x; }); }
  */
-#if defined __GNUC__ || defined __clang__ \
-    || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150)
+#if defined __GNUC__ /* both C and C++ mode */ \
+    || defined __clang__ /* both C and C++ mode */ \
+    || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) /* C mode */ \
+    || (defined __SUNPRO_CC && __SUNPRO_CC >= 0x5150) /* C++ mode */
 # define HAVE_STATEMENT_EXPRESSIONS 1
 #endif
 
    Test program:
      int f (int x) { return _Generic (x, char *: 2, int: 3); }
  */
-#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
-    || (defined __clang__ && __clang_major__ >= 3) \
-    || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150)
+#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 9) > 4 && !defined __cplusplus) /* C mode */ \
+    || (defined __clang__ && __clang_major__ >= 3) /* both C and C++ mode */ \
+    || (defined __SUNPRO_C && __SUNPRO_C >= 0x5150) /* C mode */ \
+    || __STDC_VERSION__ >= 201112L /* C mode */
 # define HAVE__GENERIC 1
 #endif
 
@@ -64,8 +67,8 @@
    Test program:
      int f (int x) { return __builtin_choose_expr (sizeof (x) == 4, 2, 3); }
  */
-#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 1) > 3) \
-    || (defined __clang__ && __clang_major__ >= 3)
+#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 1) > 3) /* both C and C++ mode */ \
+    || (defined __clang__ && __clang_major__ >= 3) /* both C and C++ mode */
 # define HAVE_BUILTIN_CHOOSE_EXPR 1
 #endif
 
@@ -77,8 +80,8 @@
    Test program:
      int i, v[__builtin_constant_p ("x") > __builtin_constant_p (i) ? 1 : -1];
  */
-#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 1) > 3) \
-    || (defined __clang__ && __clang_major__ >= 4)
+#if (defined __GNUC__ && __GNUC__ + (__GNUC_MINOR__ >= 1) > 3) /* both C and C++ mode */ \
+    || (defined __clang__ && __clang_major__ >= 4) /* both C and C++ mode */
 # define HAVE_BUILTIN_CONSTANT_P 1
 #endif