Let's say I have function accepting function pointer as argument.
void fun(void(*problematicFunPointer)(void*) problemFun){
...
}
Then, when I want to use this function like this:
void actualProblematicFun1(struct s_something * smt){
...
}
void actualProblematicFun2(struct s_something_else * smthels){
...
}
int main(){
fun(&actualProblematicFun1);
fun(&actualProblematicFun2);
}
When using -Werror, this throws compile error -Werror=incompatible-pointer-types. Is there a way to suppress warning for this particular case?
void(*)(void*). Calling the resultant pointer is then technically undefined behavior, although practically it works and is (AFAIK) the only way to get that better codegen. The C standard would want you to write a wrapper function and pass a pointer to that.