c - extern keyword with function names -
i know static
keyword makes c function/variable file-scoped. , i've read if want make variable global scope (accessed more 1 file), should do:
in .c
file:
int my_global_var; // main()....
in .h
file:
extern int my_global_var;
so, 1 include .h
file able reference my_global_var
extern
ed.
and read required functions using gcc
4.x , don't extern
function in .h file , other programs can link
it.
so, question is...
is behavior of non-static function linkage default or should extern
non-static functions adhere standard??
from standard, 6.2.2
5 if declaration of identifier function has no storage-class specifier, linkage determined if declared storage-class specifier extern. if declaration of identifier object has file scope , no storage-class specifier, linkage external.
meaning, it's extern default.
Comments
Post a Comment