#include <stdio.h>
void fun1(int *c){return;}
void fun2(void *p){return;}
void fun3(void **p){return;}
typedef void (* myfunptr)(void *);
void fun4(myfunptr b){
return;
}
int
main(){
int *p;
void *q = p;
fun1(p); //no warning
fun1(q); //no warning
fun2(p); //no warning
fun2(q); //no warning
fun3(&p); //warning - incompatible pointer types
fun3(&q); //no warning
fun4(fun1); //warning - incompatible pointer types
fun4(fun2); //no warning
return 0;
}
I am realizing warning at fun3(&p) as void ** is not a generic pointer like void *. However, I'm a little puzzled why there is a warning in the case of fun4(fun1), as void * and int * are implicitly converted without warning.
My next question is there a way I will get warnings of "incompatible types" for all non-compatible pointer conversion except when void * or void ** involved. Because using -Wno-incompatible-pointer-types disables warnings of all types of conversions.