I’m wondering why this will compile:
int test();
int main() { return test((void*)0x1234); }
int test(void* data) { return 0; }
Why won’t the compiler emit any error/warning about that (I tried clang, gcc)?
If I change the return value it won’t compile – but the arguments may differ?!
If you change:
to:
you will get the expected error:
This is because
int test();simply declares a function which takes any parameters (and is therefore compatible with your subsequent definition oftest), whereasint test(void);is an actual function prototype which declares a function which takes no parameters (and which is not compatible with the subsequent definition).