On Monday, 12 March 2018 at 01:45:54 UTC, Adam D. Ruppe wrote:
I just reformatted it but now the difference should be visible: `extern(C)` is missing on your callback.

The scope things might make a difference too, but I know for sure extern(C) is necessary on your callback function.

I saw the extern(C) and I believe I tried it before my previous post, but dismissed it because I saw no difference in compiler behavior. In any case declaring

extern (C) int compar(const (void *) p1, const (void *) p2) {
   ... // as before

still gives the 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, extern (C) int function(const(void*) p1, const(void*) p2))

It only went away with

extern (C) int compar(scope const (void *) p1, scope const (void *) p2)

Could you explain or direct me to something that elucidates why the "scope" qualifiers are needed? And is there something else that is necessary inside compar() or are the "scope"s just for decorative purposes?


Reply via email to