From 1eb6fd581f1890682ef7b39b12c5bcf37c6ee6dd Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 4 Dec 2019 12:20:44 +0100
Subject: [PATCH] Fix compilation error in C++ mode on Solaris 11 OpenIndiana.

* lib/wchar.in.h (wcsnrtombs): Force declaration in C++ mode on Solaris.
* doc/posix-functions/wcsnrtombs.texi: Mention the issue.
---
 ChangeLog                           | 6 ++++++
 doc/posix-functions/wcsnrtombs.texi | 4 ++++
 lib/wchar.in.h                      | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 805927af03..c5d8df6c13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-04  Bruno Haible  <bruno@clisp.org>
+
+	Fix compilation error in C++ mode on Solaris 11 OpenIndiana.
+	* lib/wchar.in.h (wcsnrtombs): Force declaration in C++ mode on Solaris.
+	* doc/posix-functions/wcsnrtombs.texi: Mention the issue.
+
 2019-12-04  Bruno Haible  <bruno@clisp.org>
 
 	Disable more _GL_CXXALIASWARN on all platforms other than glibc systems.
diff --git a/doc/posix-functions/wcsnrtombs.texi b/doc/posix-functions/wcsnrtombs.texi
index 39415d979f..08aeebbe8c 100644
--- a/doc/posix-functions/wcsnrtombs.texi
+++ b/doc/posix-functions/wcsnrtombs.texi
@@ -15,6 +15,10 @@ FreeBSD 5.2.1, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, HP-UX 11, IRIX 6.5, Solaris
 This function cannot consume valid sequences of wide characters
 on some platforms:
 Solaris 11.4.
+@item
+In C++ mode, the system's @code{<wchar.h>} defines @code{std::wcsnrtombs} but
+not @code{::wcsnrtombs} on some platforms:
+Solaris 11 OpenIndiana.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index f081be648d..71b1efe9ca 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -436,7 +436,7 @@ _GL_CXXALIAS_RPL (wcsnrtombs, size_t,
                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
                    mbstate_t *ps));
 # else
-#  if !@HAVE_WCSNRTOMBS@
+#  if !@HAVE_WCSNRTOMBS@ || (defined __cplusplus && defined __sun)
 _GL_FUNCDECL_SYS (wcsnrtombs, size_t,
                   (char *dest, const wchar_t **srcp, size_t srclen, size_t len,
                    mbstate_t *ps)
-- 
2.39.5