I've wondered why this hasn't been relaxed a bit when void* is used. Say you have these functions (modified from the link)
int compare (const char *a, const char *b) {
return strcmp(a, b);
}
int compare (const void *a1, const void *b1) {
const char *a = a1;
const char *b = b1;
return strcmp (a, b);
}
And then you have some FP of type int(*compare)(const void *a1, const void *b1) somewhere...If you have correct pointer const-ness, why isn't the first method the PREFERRED way of doing this? It's shorter, more clear, safer (calling compare directly and not through a FP still gets you proper type checking (you wouldn't call either of these example functions directly, but for others you might)), and IDE suggestions can better explain what the function is. I've thought several times about suggesting to compiler writers/the C committee to bless the first method. Is there some obscure hardware that the first would be incorrectly compiled or something (i.e. the calling convention for void* and foo* is different)?