From: Bruno Haible Date: Fri, 24 Dec 2021 15:51:31 +0000 (+0100) Subject: search: Fix compilation errors with SunPRO C++ on Solaris 10. X-Git-Tag: v1.0~2493 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9359e30c8d5cad401a90e7735768f7ce934abc79;p=gnulib.git search: Fix compilation errors with SunPRO C++ on Solaris 10. * lib/search.in.h (_gl_lsearch_compar_fn): New type. (lfind, lsearch): Use it. --- diff --git a/ChangeLog b/ChangeLog index 43d28ec213..dba79b9082 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2021-12-24 Bruno Haible + + search: Fix compilation errors with SunPRO C++ on Solaris 10. + * lib/search.in.h (_gl_lsearch_compar_fn): New type. + (lfind, lsearch): Use it. + 2021-12-24 Bruno Haible qsort_r: Fix compilation error with SunPRO C++ on Solaris 10. diff --git a/lib/search.in.h b/lib/search.in.h index 02faf482da..1935d8a97e 100644 --- a/lib/search.in.h +++ b/lib/search.in.h @@ -38,6 +38,17 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ +#ifdef __cplusplus +extern "C" { +#endif +#if !GNULIB_defined_lsearch_fn_types +typedef int (*_gl_lsearch_compar_fn) (const void *, const void *); +# define GNULIB_defined_lsearch_fn_types 1 +#endif +#ifdef __cplusplus +} +#endif + #if @GNULIB_MDA_LFIND@ /* On native Windows, map 'lfind' to '_lfind', so that -loldnames is not required. In C++ with GNULIB_NAMESPACE, avoid differences between @@ -50,12 +61,12 @@ _GL_CXXALIAS_MDA (lfind, void *, (const void *key, const void *base, unsigned int *nmemb, unsigned int size, - int (*compar) (const void *, const void *))); + _gl_lsearch_compar_fn compar)); # else _GL_CXXALIAS_SYS (lfind, void *, (const void *key, const void *base, size_t *nmemb, size_t size, - int (*compar) (const void *, const void *))); + _gl_lsearch_compar_fn compar)); # endif _GL_CXXALIASWARN (lfind); #endif @@ -72,12 +83,12 @@ _GL_CXXALIASWARN (lfind); _GL_CXXALIAS_MDA (lsearch, void *, (const void *key, void *base, unsigned int *nmemb, unsigned int size, - int (*compar) (const void *, const void *))); + _gl_lsearch_compar_fn compar)); # else _GL_CXXALIAS_SYS (lsearch, void *, (const void *key, void *base, size_t *nmemb, size_t size, - int (*compar) (const void *, const void *))); + _gl_lsearch_compar_fn compar)); # endif _GL_CXXALIASWARN (lsearch); #endif