]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
unistr, unigbrk: Fix compilation error in C++ mode (regr. 2025-02-09).
authorBruno Haible <bruno@clisp.org>
Fri, 3 Oct 2025 19:50:13 +0000 (21:50 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 3 Oct 2025 19:50:13 +0000 (21:50 +0200)
Reported by Ryan Carsten Schmidt <gnulib@ryandesign.com>
at <https://savannah.gnu.org/bugs/?67576>.

* 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.

ChangeLog
lib/unigbrk.in.h
lib/unistr.in.h

index b358ac895a4e87c6f325c3b82a92ee52c9918474..c24a3c46d243eae41c0279c5acd1c6270c4700ff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-10-03  Bruno Haible  <bruno@clisp.org>
+
+       unistr, unigbrk: Fix compilation error in C++ mode (regr. 2025-02-09).
+       Reported by Ryan Carsten Schmidt <gnulib@ryandesign.com>
+       at <https://savannah.gnu.org/bugs/?67576>.
+       * 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  <collin.funk1@gmail.com>
 
        xsetenv: Revert the previous change.
index 0c474632b3bef71294015f1fdf7025053e3d8af2..8a5c6051bb17f78bb1458f2d5c996eda301d517f 100644 (file)
@@ -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
index 42aea40e7e20553e7ad7b3f2109ecd6466cdbb47..4b80b1610dca21d2dd28eb60d486f7da5fb70c49 100644 (file)
@@ -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.  */