From: Bruno Haible Date: Mon, 10 Feb 2025 10:46:01 +0000 (+0100) Subject: mbsstr, etc.: Fix compilation in C++ mode on AIX with xlc. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77ec1d1ab287c18c2b4d872ca90f0e54dd76d10a;p=thirdparty%2Fgnulib.git mbsstr, etc.: Fix compilation in C++ mode on AIX with xlc. * lib/string.in.h (mbsstr, mbspcasecmp, mbscasestr): Wrap template declarations and definitions in 'extern "C++" { ... }'. --- diff --git a/ChangeLog b/ChangeLog index 0b209d20c7..eacb2bca04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-02-10 Bruno Haible + + mbsstr, etc.: Fix compilation in C++ mode on AIX with xlc. + * lib/string.in.h (mbsstr, mbspcasecmp, mbscasestr): Wrap template + declarations and definitions in 'extern "C++" { ... }'. + 2025-02-10 Bruno Haible mbsstr, unistr, unigbrk: Fix compilation with "gcc-4.8.5 -std=gnu11". diff --git a/lib/string.in.h b/lib/string.in.h index 0b7f8cebc6..ac6b459de9 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -1182,6 +1182,7 @@ _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) /* Don't silently convert a 'const char *' to a 'char *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus +extern "C++" { /* needed for AIX */ template T * mbsstr_template (T* haystack, const char *needle); template <> @@ -1190,6 +1191,7 @@ template <> template <> inline const char * mbsstr_template (const char *haystack, const char *needle) { return mbsstr (haystack, needle); } +} # define mbsstr mbsstr_template # else # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \ @@ -1247,6 +1249,7 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) /* Don't silently convert a 'const char *' to a 'char *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus +extern "C++" { /* needed for AIX */ template T * mbspcasecmp_template (T* string, const char *prefix); template <> @@ -1255,6 +1258,7 @@ template <> template <> inline const char * mbspcasecmp_template (const char *string, const char *prefix) { return mbspcasecmp (string, prefix); } +} # define mbspcasecmp mbspcasecmp_template # else # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \ @@ -1282,6 +1286,7 @@ _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) /* Don't silently convert a 'const char *' to a 'char *'. Programmers want compiler warnings for 'const' related mistakes. */ # ifdef __cplusplus +extern "C++" { /* needed for AIX */ template T * mbscasestr_template (T* haystack, const char *needle); template <> @@ -1290,6 +1295,7 @@ template <> template <> inline const char * mbscasestr_template (const char *haystack, const char *needle) { return mbscasestr (haystack, needle); } +} # define mbscasestr mbscasestr_template # else # if ((__GNUC__ + (__GNUC_MINOR__ >= 9) > 4) || (__clang_major__ >= 3) \