While I analyze some source codes, I found following definitions in one file(.c), not different file (This is one of the codes in a file produced by flex and there is no included file(stdio.h, string.h, errno.h, stdlib.h, inttypes.h) that defines yyin ):
extern FILE *yyin, *yyout;
FILE *yyin = (FILE*) 0, *yyout = (FILE *) 0;
I basically know what these statements mean.
But, extern keyword is used to make use of definitions such as variable, and function that live in another file. (It does not allocate memory for it.)
So, what I mean is that the code :
FILE *yyin = (FILE*) 0, *yyout = (FILE *) 0;
has to appear in another file, not in the same file.
For instance,
a.c
extern File *yyin; /* It means that a.c want to use yyin declared in b.c */
int main(void) {
yyin = *expressions*; /* yyin is variable in b.c */
return 0;
}
b.c
File *yyin = (FILE*) 0;
Why do they exist in the same file? Are there any special meanings when extern keyword and normal variable declaration using same name live in the same file?