Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’



On 05/16/2012 06:25 AM, Andreas Jaeger wrote:
Here's a diff for the manual, I'm getting this fixed in glibc,

Andreas

diff --git a/manual/string.texi b/manual/string.texi
index 5051f54..7abf46b 100644
--- a/manual/string.texi
+++ b/manual/string.texi
@@ -1370,8 +1370,11 @@ efficiently using @code{strxfrm}.)
/* @r{This is the comparison function used with @code{qsort}.} */

int
-compare_elements (char **p1, char **p2)
+compare_elements (const void *v1, const void *v2)
@{
+ char **p1 = (char **)v1;
+ char **p2 = (char **)v2;
+
return strcoll (*p1, *p2);
@}

@@ -1462,8 +1465,11 @@ struct sorter @{ char *input; char *transformed; @};
@r{to sort an array of @code{struct sorter}.} */

int
-compare_elements (struct sorter *p1, struct sorter *p2)
+compare_elements (const void *v1, const void *v2)
@{
+ struct sorter *p1 = (struct sorter *)v1;
+ struct sorter *p2 = (struct sorter *)v2;
+
return strcmp (p1->transformed, p2->transformed);
@}


Both compiles great. Thanks Andreas. Looks like the 2.16 manual will be a good
update to the manual that probably hasn't had a good going over in quite some
time. Thanks for all you efforts there.

--
David C. Rankin, J.D.,P.E.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx