From: Bruno Haible Date: Fri, 3 Oct 2025 19:50:13 +0000 (+0200) Subject: unistr, unigbrk: Fix compilation error in C++ mode (regr. 2025-02-09). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f2b934a627d29cbf9ef4d4fc3c63b46968a6312;p=thirdparty%2Fgnulib.git unistr, unigbrk: Fix compilation error in C++ mode (regr. 2025-02-09). Reported by Ryan Carsten Schmidt at . * lib/unistr.in.h (u*_check, u*_chr, u*_next, u*_prev, u*_strchr, u*_strrchr, u*_strpbrk, u*_strstr): Define C++ templates outside of 'extern "C"' block. * lib/unigbrk.in.h (u*_grapheme_next, u*_grapheme_prev): Likewise. --- diff --git a/ChangeLog b/ChangeLog index b358ac895a..c24a3c46d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2025-10-03 Bruno Haible + + unistr, unigbrk: Fix compilation error in C++ mode (regr. 2025-02-09). + Reported by Ryan Carsten Schmidt + at . + * lib/unistr.in.h (u*_check, u*_chr, u*_next, u*_prev, u*_strchr, + u*_strrchr, u*_strpbrk, u*_strstr): Define C++ templates outside of + 'extern "C"' block. + * lib/unigbrk.in.h (u*_grapheme_next, u*_grapheme_prev): Likewise. + 2025-09-28 Collin Funk xsetenv: Revert the previous change. diff --git a/lib/unigbrk.in.h b/lib/unigbrk.in.h index 0c474632b3..8a5c6051bb 100644 --- a/lib/unigbrk.in.h +++ b/lib/unigbrk.in.h @@ -111,6 +111,9 @@ extern const uint32_t * u32_grapheme_next (const uint32_t *s, const uint32_t *end) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -176,6 +179,9 @@ template <> default : u32_grapheme_next ((s), (end))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Returns the start of the previous grapheme cluster before S, or NULL if the @@ -192,6 +198,9 @@ extern const uint32_t * u32_grapheme_prev (const uint32_t *s, const uint32_t *start) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -257,6 +266,9 @@ template <> default : u32_grapheme_prev ((s), (start))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Determine the grapheme cluster boundaries in S, and store the result at diff --git a/lib/unistr.in.h b/lib/unistr.in.h index 42aea40e7e..4b80b1610d 100644 --- a/lib/unistr.in.h +++ b/lib/unistr.in.h @@ -82,6 +82,9 @@ extern const uint32_t * _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -147,6 +150,9 @@ template <> default : u32_check ((s), (n))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif @@ -513,6 +519,9 @@ extern uint32_t * u32_chr (const uint32_t *s, size_t n, ucs4_t uc) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -578,6 +587,9 @@ template <> default : u32_chr ((s), (n), (u))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Count the number of Unicode characters in the N units from S. */ @@ -636,6 +648,9 @@ extern const uint16_t * extern const uint32_t * u32_next (ucs4_t *puc, const uint32_t *s); #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -701,6 +716,9 @@ template <> default : u32_next ((p), (s))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Backward iteration step. Advances the pointer to point to the previous @@ -713,6 +731,9 @@ extern const uint16_t * extern const uint32_t * u32_prev (ucs4_t *puc, const uint32_t *s, const uint32_t *start); #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -778,6 +799,9 @@ template <> default : u32_prev ((p), (s), (start))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Return the number of units in S. */ @@ -926,6 +950,9 @@ extern uint32_t * u32_strchr (const uint32_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -991,6 +1018,9 @@ template <> default : u32_strchr ((s), (u))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Find the last occurrence of UC in STR. */ @@ -1005,6 +1035,9 @@ extern uint32_t * u32_strrchr (const uint32_t *str, ucs4_t uc) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -1070,6 +1103,9 @@ template <> default : u32_strrchr ((s), (u))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Return the length of the initial segment of STR which consists entirely @@ -1110,6 +1146,9 @@ extern uint32_t * u32_strpbrk (const uint32_t *str, const uint32_t *accept) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -1175,6 +1214,9 @@ template <> default : u32_strpbrk ((s), (a))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Find the first occurrence of NEEDLE in HAYSTACK. */ @@ -1189,6 +1231,9 @@ extern uint32_t * u32_strstr (const uint32_t *haystack, const uint32_t *needle) _UC_ATTRIBUTE_PURE; #ifndef _LIBUNISTRING_NO_CONST_GENERICS +# ifdef __cplusplus +} +# endif /* Don't silently convert a 'const uintN_t *' to a 'uintN_t *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus @@ -1254,6 +1299,9 @@ template <> default : u32_strstr ((h), (n))) # endif # endif +# ifdef __cplusplus +extern "C" { +# endif #endif /* Test whether STR starts with PREFIX. */