core.stdc.stdlib._compare_fp_t and qsort
Joe
jma at freedomcircle.com
Sun Mar 11 23:12:30 UTC 2018
I'm getting a compiler error in a qsort() call as follows:
qsort(recs, num_recs, (Record *).sizeof, compar);
Record is a struct, recs is a fixed array of pointers to Record's
and num_recs is a size_t that holds the number of valid records.
compar is this:
int compar(const void *p1, const void *p2)
{
import core.stdc.string : strcmp;
const Record **rp1 = cast(Record **)p1;
const Record **rp2 = cast(Record **)p2;
return strcmp((*rp1).name.ptr, (*rp2).name.ptr);
}
The error is: Error: function testd.compar (const(void*) p1,
const(void*) p2) is not callable using argument types ()
I don't quite understand what those parentheses mean: is it
implying "no arguments" and if so, where would one provide
arguments?
Joe
More information about the Digitalmars-d-learn
mailing list