|
|
|
|
|
by trealira
617 days ago
|
|
I was more referring to how, in the K&R example, a function of type "int (*)(char *, char *)" is cast to "int (*)(void *, void *)", in contradiction to what they said here: > Before someone mentions qsort(): the comparator function really is supposed to take a void*, and inside the function, you re-cast the void* argument to a pointer type of your desire. If you don't do it in that order, you're using it wrong. In contrast, the K&R example is an example of explicitly undefined behavior in the C standard: The behavior is undefined in the following circumstances: - A pointer is used to call a function whose type is not compatible with the pointed-to type (6.3.2.3). |
|
You can’t blame K&R C for that. It predates “the C standard” by over a decade (1978 vs 1989)
When it was written, what K&R said was C.