I've just met a weird-looking function declaration syntax in C, which is invalid in C++. It goes like this:
#include <stdio.h>
void my_func (foo)
int foo;
{
printf("my_func printf foo = %d\n", foo);
}
int main () {
my_func(1089);
return 0;
}
From what I could infer, it seems like it is a function definition, for which all parameters' types default to int
, and if I replace int foo;
by float foo;
, I can change the argument's type.
But can anyone confirm that this is only what is happening, why does this syntax exit? Is it a relic from the past? Why is it invalid when compiled with g++, etc.?
Thanks!