From: Bruno Haible Date: Fri, 24 Dec 2021 15:46:27 +0000 (+0100) Subject: qsort_r: Fix compilation error with SunPRO C++ on Solaris 10. X-Git-Tag: v1.0~2494 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=da9fa9b9fc07fd7f7c6bfe23396e661dc325087e;p=gnulib.git 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++. --- diff --git a/ChangeLog b/ChangeLog index 66b7fd49ab..43d28ec213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-12-24 Bruno Haible + + 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 threads-h tests: Avoid clang warnings. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 0855112d19..cb99492b3d 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -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); diff --git a/tests/test-stdlib-c++.cc b/tests/test-stdlib-c++.cc index 207944528b..c16c8a809c 100644 --- a/tests/test-stdlib-c++.cc +++ b/tests/test-stdlib-c++.cc @@ -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 *));