core.stdc.stdlib._compare_fp_t and qsort

Joe jma at freedomcircle.com
Mon Mar 12 01:04:06 UTC 2018


On Sunday, 11 March 2018 at 23:26:04 UTC, Stefan Koch wrote:
> You have to pass a pointer to the function.
> Otherwise it'll be a parenthsis-less call.
> use :  qsort(recs, num_recs, (Record *).sizeof, &compar);

After passing a pointer, getting some other error messages, I 
changed the call to

     qsort(cast(void *)recs, num_recs, cast(size_t)(Record 
*).sizeof, &compar);

and the latest error is:

Error: function core.stdc.stdlib.qsort (scope void* base, ulong 
nmemb, ulong size, extern (C) int function(scope const(void*), 
scope const(void*)) @system compar) is not callable using 
argument types (void*, ulong, ulong, int function(const(void*) 
p1, const(void*) p2))

I fail to see which argument is causing the problem now.

Joe


More information about the Digitalmars-d-learn mailing list