[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
search: Fix compilation errors with SunPRO C++ on Solaris 10
From: |
Bruno Haible |
Subject: |
search: Fix compilation errors with SunPRO C++ on Solaris 10 |
Date: |
Fri, 24 Dec 2021 16:52:21 +0100 |
On Solaris 10, with cc and CC as compilers, I get these compilation errors:
"../gllib/search.h", line 565: Error: Cannot return extern "C" void*(*)(const
void*,const void*,unsigned*,unsigned,extern "C" int(*)(const void*,const
void*)) from a function that should return void*(*)(const void*,const
void*,unsigned*,unsigned,int(*)(const void*,const void*)).
"../gllib/search.h", line 587: Error: Cannot return extern "C" void*(*)(const
void*,void*,unsigned*,unsigned,extern "C" int(*)(const void*,const void*)) from
a function that should return void*(*)(const
void*,void*,unsigned*,unsigned,int(*)(const void*,const void*)).
Apparently this compiler is picky regarding C linkage vs. C++ linkage of
function types. This patch fixes it.
2021-12-24 Bruno Haible <bruno@clisp.org>
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/lib/search.in.h b/lib/search.in.h
index 02faf482d..1935d8a97 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- search: Fix compilation errors with SunPRO C++ on Solaris 10,
Bruno Haible <=