From: Jeff King Date: Thu, 01 Dec 2016 20:26:03 GMT Subject: Re: [PATCH 1/3] compat: add qsort_s() Message-ID: <20161201202602.sfs6ycmh32ib5ed7@sigill.intra.peff.net> In-Reply-To: On Thu, Dec 01, 2016 at 12:22:37PM -0800, Junio C Hamano wrote: > Junio C Hamano writes: > > > Eh, wait. BSD and Microsoft have paramters reordered in the > > callback comparison function. I suspect that would not fly very > > well. > > Hmm. We could do it like this, which may not be too bad. Heh. Exactly, but I was too lazy to write it out in my other email. :) The no-cost version would be more like: #ifdef APPLE_QSORT_R #define DECLARE_CMP(func) int func(void *data, const void *va, const void *vb) #else #define DECLARE_CMP(func) int func(const void *va, const void *vb, void *data) #endif and then: DECLARE_CMP(foocmp); ... DECLARE_CMP(foocmp) { const struct foo *a = va, *b = vb; ... etc ... } -Peff