]> Savannah Git Hosting - gnulib.git/commitdiff
uchar: Force inline functions to C linkage in C++ mode.
authorBruno Haible <bruno@clisp.org>
Thu, 6 Apr 2023 14:14:13 +0000 (16:14 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Apr 2023 15:07:41 +0000 (17:07 +0200)
* m4/gnulib-common.m4 (gl_COMMON_BODY): Put definitions of
_GL_BEGIN_C_LINKAGE, _GL_END_C_LINKAGE into config.h.
* lib/uchar.in.h: Enclose all inline functions in _GL_BEGIN_C_LINKAGE /
_GL_END_C_LINKAGE.

ChangeLog
lib/uchar.in.h
m4/gnulib-common.m4

index 090b3280ad1d2590456d00ca18abc92e5810d307..29f2e9db685c400bd52626c1b723f92c54fffc9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-2023-04-05  Bruno Haible  <bruno@clisp.org>
+2023-04-06  Bruno Haible  <bruno@clisp.org>
+
+       uchar: Inline functions with C linkage in C++ mode (regr. 2023-04-04).
+       * m4/gnulib-common.m4 (gl_COMMON_BODY): Put definitions of
+       _GL_BEGIN_C_LINKAGE, _GL_END_C_LINKAGE into config.h.
+       * lib/uchar.in.h: Enclose all inline functions in _GL_BEGIN_C_LINKAGE /
+       _GL_END_C_LINKAGE.
+
+2023-04-06  Bruno Haible  <bruno@clisp.org>
 
        alignalloc: Fix link error on glibc 2.15 systems.
        * lib/alignalloc.h (ALIGNALLOC_VIA_ALIGNED_ALLOC): Set to 0 on
index b5554c64b6e636ffb4b66e7aa34bea3e08a5a677..4461a35901c53e549377719cd2979fb10439c4a8 100644 (file)
@@ -145,11 +145,13 @@ static_assert (sizeof (char32_t) == sizeof (wchar_t));
 /* Convert a single-byte character to a 32-bit wide character.  */
 #if @GNULIB_BTOC32@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_BTOC32
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ATTRIBUTE_PURE wint_t
 btoc32 (int c)
 {
   return btowc (c);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (btoc32, wint_t, (int c) _GL_ATTRIBUTE_PURE);
 # endif
@@ -161,11 +163,13 @@ _GL_CXXALIASWARN (btoc32);
 /* Test a specific property of a 32-bit wide character.  */
 #if @GNULIB_C32ISALNUM@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALNUM
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isalnum (wint_t wc)
 {
   return iswalnum (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isalnum, int, (wint_t wc));
 # endif
@@ -174,11 +178,13 @@ _GL_CXXALIASWARN (c32isalnum);
 #endif
 #if @GNULIB_C32ISALPHA@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISALPHA
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isalpha (wint_t wc)
 {
   return iswalpha (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isalpha, int, (wint_t wc));
 # endif
@@ -187,11 +193,13 @@ _GL_CXXALIASWARN (c32isalpha);
 #endif
 #if @GNULIB_C32ISBLANK@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISBLANK
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isblank (wint_t wc)
 {
   return iswblank (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isblank, int, (wint_t wc));
 # endif
@@ -200,11 +208,13 @@ _GL_CXXALIASWARN (c32isblank);
 #endif
 #if @GNULIB_C32ISCNTRL@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISCNTRL
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32iscntrl (wint_t wc)
 {
   return iswcntrl (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32iscntrl, int, (wint_t wc));
 # endif
@@ -213,11 +223,13 @@ _GL_CXXALIASWARN (c32iscntrl);
 #endif
 #if @GNULIB_C32ISDIGIT@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISDIGIT
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isdigit (wint_t wc)
 {
   return iswdigit (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isdigit, int, (wint_t wc));
 # endif
@@ -226,11 +238,13 @@ _GL_CXXALIASWARN (c32isdigit);
 #endif
 #if @GNULIB_C32ISGRAPH@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISGRAPH
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isgraph (wint_t wc)
 {
   return iswgraph (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isgraph, int, (wint_t wc));
 # endif
@@ -239,11 +253,13 @@ _GL_CXXALIASWARN (c32isgraph);
 #endif
 #if @GNULIB_C32ISLOWER@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISLOWER
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32islower (wint_t wc)
 {
   return iswlower (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32islower, int, (wint_t wc));
 # endif
@@ -252,11 +268,13 @@ _GL_CXXALIASWARN (c32islower);
 #endif
 #if @GNULIB_C32ISPRINT@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPRINT
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isprint (wint_t wc)
 {
   return iswprint (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isprint, int, (wint_t wc));
 # endif
@@ -265,11 +283,13 @@ _GL_CXXALIASWARN (c32isprint);
 #endif
 #if @GNULIB_C32ISPUNCT@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISPUNCT
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32ispunct (wint_t wc)
 {
   return iswpunct (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32ispunct, int, (wint_t wc));
 # endif
@@ -278,11 +298,13 @@ _GL_CXXALIASWARN (c32ispunct);
 #endif
 #if @GNULIB_C32ISSPACE@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISSPACE
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isspace (wint_t wc)
 {
   return iswspace (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isspace, int, (wint_t wc));
 # endif
@@ -291,11 +313,13 @@ _GL_CXXALIASWARN (c32isspace);
 #endif
 #if @GNULIB_C32ISUPPER@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISUPPER
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isupper (wint_t wc)
 {
   return iswupper (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isupper, int, (wint_t wc));
 # endif
@@ -304,11 +328,13 @@ _GL_CXXALIASWARN (c32isupper);
 #endif
 #if @GNULIB_C32ISXDIGIT@
 # if (_GL_WCHAR_T_IS_UCS4 && !GNULIB_defined_mbstate_t) && !defined IN_C32ISXDIGIT
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32isxdigit (wint_t wc)
 {
   return iswxdigit (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32isxdigit, int, (wint_t wc));
 # endif
@@ -347,12 +373,14 @@ _GL_WARN_ON_USE (c32rtomb, "c32rtomb is not portable - "
 /* Convert a 32-bit wide string to a string.  */
 #if @GNULIB_C32SNRTOMBS@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SNRTOMBS
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 c32snrtombs (char *dest, const char32_t **srcp, size_t srclen, size_t len,
              mbstate_t *ps)
 {
   return wcsnrtombs (dest, (const wchar_t **) srcp, srclen, len, ps);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32snrtombs, size_t,
                   (char *dest, const char32_t **srcp, size_t srclen, size_t len,
@@ -369,11 +397,13 @@ _GL_CXXALIASWARN (c32snrtombs);
 /* Convert a 32-bit wide string to a string.  */
 #if @GNULIB_C32SRTOMBS@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32SRTOMBS
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 c32srtombs (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
 {
   return wcsrtombs (dest, (const wchar_t **) srcp, len, ps);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32srtombs, size_t,
                   (char *dest, const char32_t **srcp, size_t len, mbstate_t *ps)
@@ -389,6 +419,7 @@ _GL_CXXALIASWARN (c32srtombs);
 /* Convert a 32-bit wide string to a string.  */
 #if @GNULIB_C32STOMBS@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32STOMBS
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 c32stombs (char *dest, const char32_t *src, size_t len)
 {
@@ -397,6 +428,7 @@ c32stombs (char *dest, const char32_t *src, size_t len)
   memset (&state, '\0', sizeof (mbstate_t));
   return c32srtombs (dest, &src, len, &state);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32stombs, size_t,
                   (char *dest, const char32_t *src, size_t len)
@@ -413,11 +445,13 @@ _GL_CXXALIASWARN (c32stombs);
    or EOF otherwise.  */
 #if @GNULIB_C32TOB@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_C32TOB
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE int
 c32tob (wint_t wc)
 {
   return wctob (wc);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (c32tob, int, (wint_t wc));
 # endif
@@ -460,12 +494,14 @@ _GL_WARN_ON_USE (mbrtoc32, "mbrtoc32 is not portable - "
 /* Convert a string to a 32-bit wide string.  */
 #if @GNULIB_MBSNRTOC32S@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSNRTOC32S
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 mbsnrtoc32s (char32_t *dest, const char **srcp, size_t srclen, size_t len,
              mbstate_t *ps)
 {
   return mbsnrtowcs ((wchar_t *) dest, srcp, srclen, len, ps);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (mbsnrtoc32s, size_t,
                   (char32_t *dest, const char **srcp, size_t srclen, size_t len,
@@ -482,11 +518,13 @@ _GL_CXXALIASWARN (mbsnrtoc32s);
 /* Convert a string to a 32-bit wide string.  */
 #if @GNULIB_MBSRTOC32S@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSRTOC32S
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 mbsrtoc32s (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
 {
   return mbsrtowcs ((wchar_t *) dest, srcp, len, ps);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (mbsrtoc32s, size_t,
                   (char32_t *dest, const char **srcp, size_t len, mbstate_t *ps)
@@ -502,6 +540,7 @@ _GL_CXXALIASWARN (mbsrtoc32s);
 /* Convert a string to a 32-bit wide string.  */
 #if @GNULIB_MBSTOC32S@
 # if _GL_WCHAR_T_IS_UCS4 && !defined IN_MBSTOC32S
+_GL_BEGIN_C_LINKAGE
 _GL_INLINE _GL_ARG_NONNULL ((2)) size_t
 mbstoc32s (char32_t *dest, const char *src, size_t len)
 {
@@ -510,6 +549,7 @@ mbstoc32s (char32_t *dest, const char *src, size_t len)
   memset (&state, '\0', sizeof (mbstate_t));
   return mbsrtoc32s (dest, &src, len, &state);
 }
+_GL_END_C_LINKAGE
 # else
 _GL_FUNCDECL_SYS (mbstoc32s, size_t,
                   (char32_t *dest, const char *src, size_t len)
index c84a2afd9c56d39188b9ec55e148e8b3e3960458..0df2181871d716101fc333cbcc7139d1bdbd7278 100644 (file)
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 82
+# gnulib-common.m4 serial 83
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -527,6 +527,18 @@ AC_DEFUN([gl_COMMON_BODY], [
 #  define _GL_UNUSED_LABEL
 # endif
 #endif
+])
+  AH_VERBATIM([c_linkage],
+[/* In C++, there is the concept of "language linkage", that encompasses
+    name mangling and function calling conventions.
+    The following macros start and end a block of "C" linkage.  */
+#ifdef __cplusplus
+# define _GL_BEGIN_C_LINKAGE extern "C" {
+# define _GL_END_C_LINKAGE }
+#else
+# define _GL_BEGIN_C_LINKAGE
+# define _GL_END_C_LINKAGE
+#endif
 ])
   AH_VERBATIM([async_safe],
 [/* The _GL_ASYNC_SAFE marker should be attached to functions that are