qsort1((void **) lineptr, 0, nlines - 1, (int (*)(void *, void *))(numeric ? numcmp : strcmp));Wedit output window build: Sun Feb 19 10:26:10 2017Error 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));
新聞熱點
疑難解答