pointers - Declaration of differents types of extern variables in C -
i have doubt declaration of external variables. i'm working in project working, , below (it example based in real program):
file1.h
#include "mystruct.h" extern long ; extern strc_1 s ; extern strc_2 *ss;
in main program have
main.c
#include "file1.h" long ; strc_1 s ; main() { = 10; s.variablex = 10; s.variabley = 50; ss.j = 50; ss.j = 250; }
so, question is: why not pointer 'ss' need declared in main program? , why work? mean, variables 'a' , 'strc_1' declared in main program because use them, however, use 'ss' did not declared in main program.
long ; strc_1 s ;
these in main.c
called definitions, not declarations. (to precise, definitions declarations).
the reason don't have define ss
because it's defined in other source file. long declaration of ss
(which in header1.h
) can seen, compile fine.
Comments
Post a Comment