I just noticed GCC behavior that seems strange to me (not tested by other compilers).
If I compile this code:
#include <stdio.h>
void foo(int i)
{
printf("Hello %d\n",i);
}
int main(){
foo(1, 2);
return 0;
}
I will get a compiler error:
test.c:9:5: error: too many arguments to function ‘foo’
But if I compile this code:
#include <stdio.h>
void foo()
{
printf("Hello\n");
}
int main(){
foo(1, 2);
return 0;
}
I have no errors or warnings.
Can someone explain to me why?
I tested this with gcc 4.6.3 and arm-none-eabi-gcc 4.8.3
EDIT: I am compiling all warnings: gcc -Wall test.c
source
share