In C89, does the static
keyword affect scope?
My software lead told me:
"A variable marked static at the top of a file doesn't technically have global scope any longer. Static is a scope qualifier as well as a storage keyword. Scope is a concept that covers visibility of symbols, though visibility is automatically compiled to have storage duration intrinsically tied in by almost all languages. By this I mean that you can't name a scope that doesn't also define the storage duration in C/C++. Expression scope is not user defined and in C/C++ covered by l-param and r-param Block scope is fully lexical in C/C++ by user defined bodies Function scope is fully lexical in C/C++ by user defined bodies and declarations File scope does not technically exist in C/C++, as globals and module scope take over depending upon lexicon Module scope is keyword defined using static in C/C++, other scope lexicon change the rules for access but the visibility remains module based Global scope is the default in C/C++ when no other scope applies and is lexically controlled by the extern keyword The issue is that static is not JUST a scope qualifier as a keyword. It is a scope qualifier AND a memory keyword."
I'm confused. I've always thought that static relates to the visibility between translation units and the storage duration of the variable. Both of which are unrelated to scope. Is this not the case? Is the static/scope relationship different in C++?
static
is not going to affect the scope of a symbol. It affects storage duration and linkage. – Miele