Paul Eggert wrote:
> On 2025-02-08 23:33, Bruno Haible via Gnulib discussion list wrote:
> > # define strchr(s,c) (typeof(s)) strchr ((s), (c))
> 
> This evaluates S twice if S's type is variably modified

Indeed, that's a pitfall better to be avoided.

> Also, why use typeof rather than typeof_unqual?

I thought that typeof_unqual removed the 'const'. Maybe it does so only
at the top-level, i.e. mapping  'const char *const' -> 'const char *' ?
Then typeof_unqual would be indeed just as good as typeof.

> It might be better to just use the _Generic implementation, as that 
> avoids the double-evaluation problem

Thanks for the suggestion. Done:


2025-02-09  Bruno Haible  <br...@clisp.org>

        mbsstr, mbscasestr, mbspcasecmp, unistr, unigbrk: Simplify.
        Suggested by Paul Eggert.
        * lib/string.in.h (mbsstr, mbspcasecmp, mbscasestr): On ISO C compliant
        compilers, use the _Generic based macro instead of the 'typeof' based
        macro.
        * lib/unistr.in.h (u*_check, u*_next, u*_prev, u*_chr, u*_strchr,
        u*_strrchr, u*_strpbrk, u*_strstr): Likewise.
        * lib/unigbrk.in.h (u*_grapheme_next, u*_grapheme_prev): Likewise.

diff --git a/lib/string.in.h b/lib/string.in.h
index d4c7df6258..5dbfadb3e0 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1192,10 +1192,8 @@ template <>
   { return mbsstr (haystack, needle); }
 #   define mbsstr mbsstr_template
 #  else
-#   if __STDC_VERSION__ >= 202311
-#    define mbsstr(h,n) (typeof ((h) + 0)) mbsstr ((h), (n))
-#   elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-          || defined __ICC  || defined __TINYC__)
+#   if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+        || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #    define mbsstr(h,n) \
        _Generic ((h), \
                  char const *: (char const *) mbsstr ((h), (n)), \
@@ -1258,10 +1256,8 @@ template <>
   { return mbspcasecmp (string, prefix); }
 #   define mbspcasecmp mbspcasecmp_template
 #  else
-#   if __STDC_VERSION__ >= 202311
-#    define mbspcasecmp(s,p) (typeof ((s) + 0)) mbspcasecmp ((s), (p))
-#   elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-          || defined __ICC  || defined __TINYC__)
+#   if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+        || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #    define mbspcasecmp(s,p) \
        _Generic ((s), \
                  char const *: (char const *) mbspcasecmp ((s), (p)), \
@@ -1294,10 +1290,8 @@ template <>
   { return mbscasestr (haystack, needle); }
 #   define mbscasestr mbscasestr_template
 #  else
-#   if __STDC_VERSION__ >= 202311
-#    define mbscasestr(h,n) (typeof ((h) + 0)) mbscasestr ((h), (n))
-#   elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-          || defined __ICC  || defined __TINYC__)
+#   if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+        || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #    define mbscasestr(h,n) \
        _Generic ((h), \
                  char const *: (char const *) mbscasestr ((h), (n)), \
diff --git a/lib/unigbrk.in.h b/lib/unigbrk.in.h
index 19c3e0771b..f5a8bcf700 100644
--- a/lib/unigbrk.in.h
+++ b/lib/unigbrk.in.h
@@ -124,10 +124,8 @@ template <>
   { return u8_grapheme_next (s, end); }
 #  define u8_grapheme_next u8_grapheme_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_grapheme_next(s,end) (typeof ((s) + 0)) u8_grapheme_next ((s), 
(end))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_grapheme_next(s,end) \
       _Generic ((s), \
                 uint8_t *: (uint8_t *) u8_grapheme_next ((s), (end)), \
@@ -145,10 +143,8 @@ template <>
   { return u16_grapheme_next (s, end); }
 #  define u16_grapheme_next u16_grapheme_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_grapheme_next(s,end) (typeof ((s) + 0)) u16_grapheme_next ((s), 
(end))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_grapheme_next(s,end) \
       _Generic ((s), \
                 uint16_t *: (uint16_t *) u16_grapheme_next ((s), (end)), \
@@ -166,10 +162,8 @@ template <>
   { return u32_grapheme_next (s, end); }
 #  define u32_grapheme_next u32_grapheme_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_grapheme_next(s,end) (typeof ((s) + 0)) u32_grapheme_next ((s), 
(end))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_grapheme_next(s,end) \
       _Generic ((s), \
                 uint32_t *: (uint32_t *) u32_grapheme_next ((s), (end)), \
@@ -205,10 +199,8 @@ template <>
   { return u8_grapheme_prev (s, start); }
 #  define u8_grapheme_prev u8_grapheme_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_grapheme_prev(s,start) (typeof ((s) + 0)) u8_grapheme_prev ((s), 
(start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_grapheme_prev(s,start) \
       _Generic ((s), \
                 uint8_t *: (uint8_t *) u8_grapheme_prev ((s), (start)), \
@@ -226,10 +218,8 @@ template <>
   { return u16_grapheme_prev (s, start); }
 #  define u16_grapheme_prev u16_grapheme_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_grapheme_prev(s,start) (typeof ((s) + 0)) u16_grapheme_prev 
((s), (start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_grapheme_prev(s,start) \
       _Generic ((s), \
                 uint16_t *: (uint16_t *) u16_grapheme_prev ((s), (start)), \
@@ -247,10 +237,8 @@ template <>
   { return u32_grapheme_prev (s, start); }
 #  define u32_grapheme_prev u32_grapheme_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_grapheme_prev(s,start) (typeof ((s) + 0)) u32_grapheme_prev 
((s), (start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_grapheme_prev(s,start) \
       _Generic ((s), \
                 uint32_t *: (uint32_t *) u32_grapheme_prev ((s), (start)), \
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index fd5e0067b2..e80e34e5a9 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -95,10 +95,8 @@ template <>
   { return u8_check (s, n); }
 #  define u8_check u8_check_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_check(s,n) (typeof ((s) + 0)) u8_check ((s), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_check(s,n) \
       _Generic ((s), \
                 uint8_t *: (uint8_t *) u8_check ((s), (n)), \
@@ -116,10 +114,8 @@ template <>
   { return u16_check (s, n); }
 #  define u16_check u16_check_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_check(s,n) (typeof ((s) + 0)) u16_check ((s), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_check(s,n) \
       _Generic ((s), \
                 uint16_t *: (uint16_t *) u16_check ((s), (n)), \
@@ -137,10 +133,8 @@ template <>
   { return u32_check (s, n); }
 #  define u32_check u32_check_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_check(s,n) (typeof ((s) + 0)) u32_check ((s), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_check(s,n) \
       _Generic ((s), \
                 uint32_t *: (uint32_t *) u32_check ((s), (n)), \
@@ -526,10 +520,8 @@ template <>
   { return u8_chr (str, n, uc); }
 #  define u8_chr u8_chr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_chr(s,n,u) (typeof ((s) + 0)) u8_chr ((s), (n), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_chr(s,n,u) \
       _Generic ((s), \
                 uint8_t const *: (uint8_t const *) u8_chr ((s), (n), (u)), \
@@ -547,10 +539,8 @@ template <>
   { return u16_chr (str, n, uc); }
 #  define u16_chr u16_chr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_chr(s,n,u) (typeof ((s) + 0)) u16_chr ((s), (n), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_chr(s,n,u) \
       _Generic ((s), \
                 uint16_t const *: (uint16_t const *) u16_chr ((s), (n), (u)), \
@@ -568,10 +558,8 @@ template <>
   { return u32_chr (str, n, uc); }
 #  define u32_chr u32_chr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_chr(s,n,u) (typeof ((s) + 0)) u32_chr ((s), (n), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_chr(s,n,u) \
       _Generic ((s), \
                 uint32_t const *: (uint32_t const *) u32_chr ((s), (n), (u)), \
@@ -649,10 +637,8 @@ template <>
   { return u8_next (puc, s); }
 #  define u8_next u8_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_next(p,s) (typeof ((s) + 0)) u8_next ((p), (s))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_next(p,s) \
       _Generic ((s), \
                 uint8_t *: (uint8_t *) u8_next ((p), (s)), \
@@ -670,10 +656,8 @@ template <>
   { return u16_next (puc, s); }
 #  define u16_next u16_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_next(p,s) (typeof ((s) + 0)) u16_next ((p), (s))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_next(p,s) \
       _Generic ((s), \
                 uint16_t *: (uint16_t *) u16_next ((p), (s)), \
@@ -691,10 +675,8 @@ template <>
   { return u32_next (puc, s); }
 #  define u32_next u32_next_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_next(p,s) (typeof ((s) + 0)) u32_next ((p), (s))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_next(p,s) \
       _Generic ((s), \
                 uint32_t *: (uint32_t *) u32_next ((p), (s)), \
@@ -726,10 +708,8 @@ template <>
   { return u8_prev (puc, s, start); }
 #  define u8_prev u8_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_prev(p,s,start) (typeof ((s) + 0)) u8_prev ((p), (s), (start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_prev(p,s,start) \
       _Generic ((s), \
                 uint8_t *: (uint8_t *) u8_prev ((p), (s), (start)), \
@@ -747,10 +727,8 @@ template <>
   { return u16_prev (puc, s, start); }
 #  define u16_prev u16_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_prev(p,s,start) (typeof ((s) + 0)) u16_prev ((p), (s), (start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_prev(p,s,start) \
       _Generic ((s), \
                 uint16_t *: (uint16_t *) u16_prev ((p), (s), (start)), \
@@ -768,10 +746,8 @@ template <>
   { return u32_prev (puc, s, start); }
 #  define u32_prev u32_prev_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_prev(p,s,start) (typeof ((s) + 0)) u32_prev ((p), (s), (start))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_prev(p,s,start) \
       _Generic ((s), \
                 uint32_t *: (uint32_t *) u32_prev ((p), (s), (start)), \
@@ -939,10 +915,8 @@ template <>
   { return u8_strchr (str, uc); }
 #  define u8_strchr u8_strchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_strchr(s,u) (typeof ((s) + 0)) u8_strchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_strchr(s,u) \
       _Generic ((s), \
                 uint8_t const *: (uint8_t const *) u8_strchr ((s), (u)), \
@@ -960,10 +934,8 @@ template <>
   { return u16_strchr (str, uc); }
 #  define u16_strchr u16_strchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_strchr(s,u) (typeof ((s) + 0)) u16_strchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_strchr(s,u) \
       _Generic ((s), \
                 uint16_t const *: (uint16_t const *) u16_strchr ((s), (u)), \
@@ -981,10 +953,8 @@ template <>
   { return u32_strchr (str, uc); }
 #  define u32_strchr u32_strchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_strchr(s,u) (typeof ((s) + 0)) u32_strchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_strchr(s,u) \
       _Generic ((s), \
                 uint32_t const *: (uint32_t const *) u32_strchr ((s), (u)), \
@@ -1018,10 +988,8 @@ template <>
   { return u8_strrchr (str, uc); }
 #  define u8_strrchr u8_strrchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_strrchr(s,u) (typeof ((s) + 0)) u8_strrchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_strrchr(s,u) \
       _Generic ((s), \
                 uint8_t const *: (uint8_t const *) u8_strrchr ((s), (u)), \
@@ -1039,10 +1007,8 @@ template <>
   { return u16_strrchr (str, uc); }
 #  define u16_strrchr u16_strrchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_strrchr(s,u) (typeof ((s) + 0)) u16_strrchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_strrchr(s,u) \
       _Generic ((s), \
                 uint16_t const *: (uint16_t const *) u16_strrchr ((s), (u)), \
@@ -1060,10 +1026,8 @@ template <>
   { return u32_strrchr (str, uc); }
 #  define u32_strrchr u32_strrchr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_strrchr(s,u) (typeof ((s) + 0)) u32_strrchr ((s), (u))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_strrchr(s,u) \
       _Generic ((s), \
                 uint32_t const *: (uint32_t const *) u32_strrchr ((s), (u)), \
@@ -1123,10 +1087,8 @@ template <>
   { return u8_strpbrk (str, accept); }
 #  define u8_strpbrk u8_strpbrk_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_strpbrk(s,a) (typeof ((s) + 0)) u8_strpbrk ((s), (a))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_strpbrk(s,a) \
       _Generic ((s), \
                 uint8_t const *: (uint8_t const *) u8_strpbrk ((s), (a)), \
@@ -1144,10 +1106,8 @@ template <>
   { return u16_strpbrk (str, accept); }
 #  define u16_strpbrk u16_strpbrk_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_strpbrk(s,a) (typeof ((s) + 0)) u16_strpbrk ((s), (a))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_strpbrk(s,a) \
       _Generic ((s), \
                 uint16_t const *: (uint16_t const *) u16_strpbrk ((s), (a)), \
@@ -1165,10 +1125,8 @@ template <>
   { return u32_strpbrk (str, accept); }
 #  define u32_strpbrk u32_strpbrk_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_strpbrk(s,a) (typeof ((s) + 0)) u32_strpbrk ((s), (a))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_strpbrk(s,a) \
       _Generic ((s), \
                 uint32_t const *: (uint32_t const *) u32_strpbrk ((s), (a)), \
@@ -1202,10 +1160,8 @@ template <>
   { return u8_strstr (haystack, needle); }
 #  define u8_strstr u8_strstr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u8_strstr(h,n) (typeof ((h) + 0)) u8_strstr ((h), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u8_strstr(h,n) \
       _Generic ((h), \
                 uint8_t const *: (uint8_t const *) u8_strstr ((h), (n)), \
@@ -1223,10 +1179,8 @@ template <>
   { return u16_strstr (haystack, needle); }
 #  define u16_strstr u16_strstr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u16_strstr(h,n) (typeof ((h) + 0)) u16_strstr ((h), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u16_strstr(h,n) \
       _Generic ((h), \
                 uint16_t const *: (uint16_t const *) u16_strstr ((h), (n)), \
@@ -1244,10 +1198,8 @@ template <>
   { return u32_strstr (haystack, needle); }
 #  define u32_strstr u32_strstr_template
 # else
-#  if __STDC_VERSION__ >= 202311
-#   define u32_strstr(h,n) (typeof ((h) + 0)) u32_strstr ((h), (n))
-#  elif ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \
-         || defined __ICC  || defined __TINYC__)
+#  if (__STDC_VERSION__ >= 201112L || (__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) \
+       || (__clang_major__ >= 3) || defined __ICC  || defined __TINYC__)
 #   define u32_strstr(h,n) \
       _Generic ((h), \
                 uint32_t const *: (uint32_t const *) u32_strstr ((h), (n)), \




Reply via email to