I found this line in stdio.h :
extern struct _IO_FILE *stdin;
Based on this 'extern' keyword, i assume this is just a declaration. I wonder where is stdin defined and initialized?
I found this line in stdio.h :
extern struct _IO_FILE *stdin;
Based on this 'extern' keyword, i assume this is just a declaration. I wonder where is stdin defined and initialized?
The C standard explicitly states that stdin is a macro defined in stdio.h. It is not allowed to be defined anywhere else.
C11 7.21.1
"The header
<stdio.h>defines several macros, ..." /--/"The macros are..." /--/
stderr
stdin
stdoutwhich are expressions of type ‘‘pointer to FILE’’ that point to the FILE objects associated, respectively, with the standard error, input, and output streams.
This macro can of course point at implementation details that are implemented elsewhere, such as in a "stdio.c" or whatever the compiler library chose to put it.