]> Savannah Git Hosting - gnulib.git/commitdiff
wchar: Fix compilation errors in C++ mode on Solaris 11.3.
authorBruno Haible <bruno@clisp.org>
Sun, 18 Sep 2022 01:05:21 +0000 (03:05 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 18 Sep 2022 19:22:41 +0000 (21:22 +0200)
* lib/wchar.in.h (wcsnlen, wcpcpy, wcpncpy, wcscasecmp, wcsncasecmp,
wcsdup): Force declaration in C++ mode on Solaris (which does not
declare these functions in the global namespace).

ChangeLog
lib/wchar.in.h

index f280a860e0e5f4947c64abc15188ab6db067bbda..52106a47655281d2301d02b450de3bb63b4f7bc6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-09-17  Bruno Haible  <bruno@clisp.org>
+
+       wchar: Fix compilation errors in C++ mode on Solaris 11.3.
+       * lib/wchar.in.h (wcsnlen, wcpcpy, wcpncpy, wcscasecmp, wcsncasecmp,
+       wcsdup): Force declaration in C++ mode on Solaris (which does not
+       declare these functions in the global namespace).
+
 2022-09-17  Bruno Haible  <bruno@clisp.org>
 
        swab: Fix compilation error with Sun C++ on Solaris 11.3.
index 835ddbe65924ad46e481fd8461c1e8c8de2ab5ca..3558adfb9d5d34b62475c4e61f7e30eb8b72535b 100644 (file)
@@ -745,7 +745,10 @@ _GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
 
 /* Return the number of wide characters in S, but at most MAXLEN.  */
 #if @GNULIB_WCSNLEN@
-# if !@HAVE_WCSNLEN@
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+# if !@HAVE_WCSNLEN@ || (defined __sun && defined __cplusplus)
 _GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
                                    _GL_ATTRIBUTE_PURE);
 # endif
@@ -782,7 +785,10 @@ _GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
 
 /* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST.  */
 #if @GNULIB_WCPCPY@
-# if !@HAVE_WCPCPY@
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+# if !@HAVE_WCPCPY@ || (defined __sun && defined __cplusplus)
 _GL_FUNCDECL_SYS (wcpcpy, wchar_t *,
                   (wchar_t *restrict dest, const wchar_t *restrict src));
 # endif
@@ -823,7 +829,10 @@ _GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
 /* Copy no more than N characters of SRC to DEST, returning the address of
    the last character written into DEST.  */
 #if @GNULIB_WCPNCPY@
-# if !@HAVE_WCPNCPY@
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+# if !@HAVE_WCPNCPY@ || (defined __sun && defined __cplusplus)
 _GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
                   (wchar_t *restrict dest,
                    const wchar_t *restrict src, size_t n));
@@ -925,7 +934,10 @@ _GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
 
 /* Compare S1 and S2, ignoring case.  */
 #if @GNULIB_WCSCASECMP@
-# if !@HAVE_WCSCASECMP@
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+# if !@HAVE_WCSCASECMP@ || (defined __sun && defined __cplusplus)
 _GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
                                    _GL_ATTRIBUTE_PURE);
 # endif
@@ -942,7 +954,10 @@ _GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
 
 /* Compare no more than N chars of S1 and S2, ignoring case.  */
 #if @GNULIB_WCSNCASECMP@
-# if !@HAVE_WCSNCASECMP@
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+# if !@HAVE_WCSNCASECMP@ || (defined __sun && defined __cplusplus)
 _GL_FUNCDECL_SYS (wcsncasecmp, int,
                   (const wchar_t *s1, const wchar_t *s2, size_t n)
                   _GL_ATTRIBUTE_PURE);
@@ -1009,7 +1024,10 @@ _GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
 #  endif
 _GL_CXXALIAS_MDA (wcsdup, wchar_t *, (const wchar_t *s));
 # else
-#  if !@HAVE_WCSDUP@ || __GNUC__ >= 11
+/* On Solaris 11.3, the header files declare the function in the std::
+   namespace, not in the global namespace.  So, force a declaration in
+   the global namespace.  */
+#  if !@HAVE_WCSDUP@ || (defined __sun && defined __cplusplus) || __GNUC__ >= 11
 _GL_FUNCDECL_SYS (wcsdup, wchar_t *,
                   (const wchar_t *s)
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);