qsort1((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? numcmp : strcmp));
Wedit output window build: Sun Feb 19 10:26:10 2017
Error h:\c_workcarbin\mytest.c: 26 operands of ?: have illegal types 'pointer to int function(pointer to char,pointer to char)' and 'pointer to int function(pointer to char,pointer to char)'
Compilation + link time:0.0 sec, Return code: 1
编译环境:LCC-WIN32
(1)按如下定义后,用fun1,fun2去替换numcmp,strcmp可以编译通过。
// int (*fun1)(void *,void*) = (int (*)(void *, void *)) &numcmp;
// int (*fun2)(void *,void*) = (int (*)(void *, void *)) &strcmp;
(2)或者,将强制类型转换分别对numcmp,strcmp做一遍,也可以通过编译。
qsort1((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? (int (*)(void *, void *))numcmp : (int (*)(void *, void *))strcmp));