]> Savannah Git Hosting - gnulib.git/commitdiff
string: Fix compilation error in C++ mode.
authorBruno Haible <bruno@clisp.org>
Sun, 10 May 2020 16:14:38 +0000 (18:14 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 10 May 2020 16:18:39 +0000 (18:18 +0200)
* lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): In C mode, use plain
_GL_WARN_ON_USE.
* lib/string.in.h (strchr, strpbrk, strrchr): Use _GL_WARN_ON_USE_CXX
instead of _GL_WARN_ON_USE.

ChangeLog
lib/string.in.h
lib/warn-on-use.h

index 1ba1c5f97dad5e15a690df37551ccb19850f7524..111cf89def97672a01a05c4ab740458bc25486ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-10  Bruno Haible  <bruno@clisp.org>
+
+       string: Fix compilation error in C++ mode.
+       * lib/warn-on-use.h (_GL_WARN_ON_USE_CXX): In C mode, use plain
+       _GL_WARN_ON_USE.
+       * lib/string.in.h (strchr, strpbrk, strrchr): Use _GL_WARN_ON_USE_CXX
+       instead of _GL_WARN_ON_USE.
+
 2020-05-10  Akim Demaille  <akim@lrde.epita.fr>
 
        announce-gen: add support for dist-lzip
@@ -15,6 +23,8 @@
        Pacify gcc 10’s -Wreturn-local-addr option.
        Simplify some of the later code.
 
+2020-05-09  Paul Eggert  <eggert@cs.ucla.edu>
+
        attribute: remove ATTRIBUTE_DEPRECATED
        * lib/attribute.h: Improve recently-added comments, mostly
        by shortening them (use active voice, etc.).
index d6014503152ad5946e91ab347ade066c2fc5801b..77ccf94e28351fc20e0ec33cb25ba6a1d6593164 100644 (file)
@@ -334,9 +334,10 @@ _GL_WARN_ON_USE (stpncpy, "stpncpy is unportable - "
    GB18030 and the character to be searched is a digit.  */
 # undef strchr
 /* Assume strchr is always declared.  */
-_GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
-                 "in some multibyte locales - "
-                 "use mbschr if you care about internationalization");
+_GL_WARN_ON_USE_CXX (strchr, const char *, (const char *, int),
+                     "strchr cannot work correctly on character strings "
+                     "in some multibyte locales - "
+                     "use mbschr if you care about internationalization");
 #endif
 
 /* Find the first occurrence of C in S or the final NUL byte.  */
@@ -528,15 +529,17 @@ _GL_CXXALIASWARN (strpbrk);
    locale encoding is GB18030 and one of the characters to be searched is a
    digit.  */
 #  undef strpbrk
-_GL_WARN_ON_USE (strpbrk, "strpbrk cannot work correctly on character strings "
-                 "in multibyte locales - "
-                 "use mbspbrk if you care about internationalization");
+_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
+                     "strpbrk cannot work correctly on character strings "
+                     "in multibyte locales - "
+                     "use mbspbrk if you care about internationalization");
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strpbrk
 # if HAVE_RAW_DECL_STRPBRK
-_GL_WARN_ON_USE (strpbrk, "strpbrk is unportable - "
-                 "use gnulib module strpbrk for portability");
+_GL_WARN_ON_USE_CXX (strpbrk, const char *, (const char *, const char *),
+                     "strpbrk is unportable - "
+                     "use gnulib module strpbrk for portability");
 # endif
 #endif
 
@@ -555,9 +558,10 @@ _GL_WARN_ON_USE (strspn, "strspn cannot work correctly on character strings "
    GB18030 and the character to be searched is a digit.  */
 # undef strrchr
 /* Assume strrchr is always declared.  */
-_GL_WARN_ON_USE (strrchr, "strrchr cannot work correctly on character strings "
-                 "in some multibyte locales - "
-                 "use mbsrchr if you care about internationalization");
+_GL_WARN_ON_USE_CXX (strrchr, const char *, (const char *, int),
+                     "strrchr cannot work correctly on character strings "
+                     "in some multibyte locales - "
+                     "use mbsrchr if you care about internationalization");
 #endif
 
 /* Search the next delimiter (char listed in DELIM) starting at *STRINGP.
index 1cf5770d36624daa05a4fab16d6f8b37c018190c..291e7091b887469fc681084fb1ac6a352cd480f1 100644 (file)
@@ -100,23 +100,28 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
 #endif
 
 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
-   is like _GL_WARN_ON_USE (function, "string"), except that the function is
-   declared with the given prototype, consisting of return type, parameters,
-   and attributes.
+   is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the
+   function is declared with the given prototype, consisting of return type,
+   parameters, and attributes.
    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
    not work in this case.  */
 #ifndef _GL_WARN_ON_USE_CXX
-# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+# if !defined __cplusplus
 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+     _GL_WARN_ON_USE (function, msg)
+# else
+#  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
+#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 extern rettype function parameters_and_attributes \
      __attribute__ ((__warning__ (msg)))
-# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+#  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
 /* Verify the existence of the function.  */
-#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 extern rettype function parameters_and_attributes
-# else /* Unsupported.  */
-#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+#  else /* Unsupported.  */
+#   define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
 _GL_WARN_EXTERN_C int _gl_warn_on_use
+#  endif
 # endif
 #endif