qsort_r argument order
Dustin Lang
dstn@cs.toronto.edu
Tue Dec 2 18:05:00 GMT 2008
Hi,
Apologies if this has come up before: it seems the mailing list archive
search program can't handle search words with underscores in them.
I suppose this comment is coming too late, but I really wish that the
qsort_r function had been done differently. As far as I can tell, qsort_r
is not part of any standard, but it exists in BSD (including Mac OSX).
For some reason that I can't comprehend, when it was added to glibc the
argument order was permuted.
glibc:
extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
__compar_d_fn_t __compar, void *__arg)
__nonnull ((1, 4));
BSD:
void qsort_r(void *base, size_t nel, size_t width, void *thunk,
int (*compar)(void *, const void *, const void *));
Why?! As far as I can tell, the functions would otherwise be compatible.
Especially annoying is the fact that it still compiles -- it's only at
runtime that it explodes in a fiery mess. As the developer of a software
package that uses qsort_r and has to run on BSD and glibc, this is just a
pain in the @$$.
Argh. Time to add a bunch of stupid preprocessor QSORT_Rs to my code.
cheers,
dstn.
More information about the Libc-alpha
mailing list