In this example i'm getting a Conflicting types
error as expected:
#include <stdio.h>
int a(int b);
int a(int *b){
return 6;
}
int main(){
return 0;
}
But not in this example:
#include <stdio.h>
int a(int b);
int a(){
return 6;
}
int main(){
return 0;
}
Why the second example is compiling fine although the declaration and definition and of a
are still different?
Because in C (but not C++), a()
declares a function with an unspecified number of parameters. Use a(void)
instead.