]> Savannah Git Hosting - gnulib.git/commitdiff
qsort_r: Fix compilation error with SunPRO C++ on Solaris 10.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2021 15:46:27 +0000 (16:46 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2021 15:46:27 +0000 (16:46 +0100)
* lib/stdlib.in.h (_gl_qsort_r_compar_fn): New type.
(qsort_r): Use it.
* tests/test-stdlib-c++.cc (qsort_r): Don't test with SunPRO C++.

ChangeLog
lib/stdlib.in.h
tests/test-stdlib-c++.cc

index 66b7fd49ab371770615a66f8eba42650d9c410be..43d28ec21395d47e07ab9bfb200e511c48069245 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-12-24  Bruno Haible  <bruno@clisp.org>
+
+       qsort_r: Fix compilation error with SunPRO C++ on Solaris 10.
+       * lib/stdlib.in.h (_gl_qsort_r_compar_fn): New type.
+       (qsort_r): Use it.
+       * tests/test-stdlib-c++.cc (qsort_r): Don't test with SunPRO C++.
+
 2021-12-24  Bruno Haible  <bruno@clisp.org>
 
        threads-h tests: Avoid clang warnings.
index 0855112d19e4cb79ed2aefebf42c459c90aa38d7..cb99492b3dbb53afeac4455cf5b93eb4c1cc6608 100644 (file)
@@ -828,29 +828,35 @@ _GL_CXXALIASWARN (putenv);
 /* Sort an array of NMEMB elements, starting at address BASE, each element
    occupying SIZE bytes, in ascending order according to the comparison
    function COMPARE.  */
+# ifdef __cplusplus
+extern "C" {
+# endif
+# if !GNULIB_defined_qsort_r_fn_types
+typedef int (*_gl_qsort_r_compar_fn) (void const *, void const *, void *);
+#  define GNULIB_defined_qsort_r_fn_types 1
+# endif
+# ifdef __cplusplus
+}
+# endif
 # if @REPLACE_QSORT_R@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef qsort_r
 #   define qsort_r rpl_qsort_r
 #  endif
 _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
-                                  int (*compare) (void const *, void const *,
-                                                  void *),
+                                  _gl_qsort_r_compar_fn compare,
                                   void *arg) _GL_ARG_NONNULL ((1, 4)));
 _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
-                                  int (*compare) (void const *, void const *,
-                                                  void *),
+                                  _gl_qsort_r_compar_fn compare,
                                   void *arg));
 # else
 #  if !@HAVE_QSORT_R@
 _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
-                                  int (*compare) (void const *, void const *,
-                                                  void *),
+                                  _gl_qsort_r_compar_fn compare,
                                   void *arg) _GL_ARG_NONNULL ((1, 4)));
 #  endif
 _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
-                                  int (*compare) (void const *, void const *,
-                                                  void *),
+                                  _gl_qsort_r_compar_fn compare,
                                   void *arg));
 # endif
 _GL_CXXALIASWARN (qsort_r);
index 207944528b8072b8850909baf712c08ebd28d403..c16c8a809cd66a853311cd68a344a894c162e496 100644 (file)
@@ -114,7 +114,7 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::ptsname_r, int, (int, char *, size_t));
 SIGNATURE_CHECK (GNULIB_NAMESPACE::putenv, int, (char *));
 #endif
 
-#if GNULIB_TEST_QSORT_R
+#if GNULIB_TEST_QSORT_R && !defined __SUNPRO_CC
 SIGNATURE_CHECK (GNULIB_NAMESPACE::qsort_r, void,
                  (void *, size_t, size_t,
                   int (*) (void const *, void const *, void *), void *));