Duplicate (or near duplicate):
Lately I have been working my way through the C Programming Language by K&R.
In section 5.11 they cover pointers to functions and after typing in their example -- a quicksort implementation where we provide a pointer to the comparison function we want to use -- I'm getting a warning from the compiler: pointer type mismatch in conditional expression. (My compiler is gcc 4.0.1 on OS X 10.5.6)
The line from the example that triggers the warning is:
qsort((void **) lineptr, 0, nlines-1,
(int (*)(void*, void*))(numeric ? numcmp : strcmp));
The program executes without segfaulting, but I like to smoosh every warning I can, or at least understand their causes.
The function declaration for numcmp looks like:
int numcmp(char *, char *);
But according to the manpage, stcmp has this signature:
int strcmp(const char *s1, const char *s2);
Is the warning simple because of the slightly different method signatures? What are the consequences of ignoring the warning?