[opensuse] Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- From: Dirk Gently <dirk.gently00@xxxxxxxxx>
- Date: Wed, 16 May 2012 21:01:56 -0400
David C. Rankin wrote:
On 05/16/2012 08:44 AM, David C. Rankin wrote:
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.
Andreas,
From the other thread concerning using char foo[] instead of char *foo,
couldn't the sort_strings_fast prototype (section 5.6) be improved by doing:
sort_strings_fast (char *array[], int nstrings);
instead of the current
sort_strings_fast (char **array, int nstrings);
Wouldn't that give of the same benefit of having an array of pointers to
strings instead of an array of pointer variables? It may not make any difference
here, but I thought I would pass it along anyway.
They dereference at the same speed, but the argument declaration
char **array allows for more flexibility for the caller than char *array[].
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx
- References:
- [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- From: David C. Rankin
- Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- From: Andreas Jaeger
- Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- From: David C. Rankin
- Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- From: David C. Rankin
- [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- Prev by Date: Re: [opensuse] Amarok will not play after KDE 4.8.2 or 4.8.3 and patches
- Next by Date: [opensuse] Re: how to protect from govt monitoring and anti p2p with opensuse?
- Previous by thread: Re: [opensuse] glibc example - qsort muppet warnings - stdlib.h expected ‘__compar_fn_t’
- Next by thread: [opensuse] Forum website down?
- Index(es):
Relevant Pages
|