In C, I did not notice any effect of the extern
keyword used before function declaration.
At first, I thought that when defining extern int f();
in a single file forces you to implement it outside of the file’s scope. However I found out that both:
extern int f();
int f() {return 0;}
and
extern int f() {return 0;}
compile just fine, with no warnings from gcc. I used gcc -Wall -ansi
; it wouldn’t even accept //
comments.
Are there any effects for using extern
before function definitions? Or is it just an optional keyword with no side effects for functions.
In the latter case I don’t understand why did the standard designers chose to litter the grammar with superfluous keywords.
EDIT: To clarify, I know there’s usage for extern
in variables, but I’m only asking about extern
in functions.