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



Relevant Pages

  • Re: Prime Numbers
    ... /*This code finally compiles as a 'c' code ... One more question....if i don't free up the memory allocated at the end ... it would appear that we are best served by an array ... prime numbers can be represented by an unsigned long int. ...
    (comp.lang.c)
  • Re: Newbie questions
    ... It compiles ... float getLowest(float array, int length); ... float getLowest(float array[], int length) { ... before printing a second prompt. ...
    (comp.lang.c)
  • Re: malloc and maximum size
    ... int main{ ... Change the array size to -1/2 and it compiles and prints ... same error message. ...
    (comp.lang.c)
  • Specifying global array size with const int
    ... int main ... Using the #define compiles with no errors, ... part of C to refuse to compile above code with a const int specifying ... array size, when the array is declared global? ...
    (comp.lang.c)
  • Re: argv/pointer problems
    ... > - although this does not alter whether or not it compiles. ... > This may be adaft question, but what is it that makes the ... When defining an array, you _always_ need a size for it. ... int main ...
    (comp.lang.cpp)