Possible Duplicate:
What is useful about this C syntax?
C variable declarations after function heading in definition
What weird C syntax is this?
I’m trying to understand some code and it has something like the following:
int getr(fget)
FILE *fget;
{
/* More declarations and statements here */
return (1);
}
Is there any difference between the above and:
int getr(fget)
{
FILE *fget;
/* More declarations and statements here */
return (1);
}
If so, how do they differ?
Both functions are declared in the old-style (non-prototype) form. Old-style function declarations are obsolescent in the current C standard and their use is strongly discouraged by the C Standard.
In the second form there is no mention of the
fgetparameter type which is assumed to be anint. Then another objectfgetof typeFILE *is declared and it shadows the parameter variable with the same name.With
gccthe-Wshadowwarning option would get you a warning in your second example because of the shadowing of the parameter: