C spec says
There are four types of areas: function, file, block, and function prototype.
Now, if I do the following outside of any function
struct A { int x; };
I understand that the identifier x displayed in the file area. And we use the namespace syntax to access the member, as the spec says
each structure or union has a separate namespace for its members (ambiguous in the type of expression used to access the element through an operator. or โ)
Let me make this clearer by adding a function
struct A { int x; }; void f(void) { int i; }
Then the identifiers, regions, and namespaces involved in this representation of the program (N / A "not applicable"):
file scope ========================================== Ordinary | Members A | Tags | Labels ------------------------------------------ f | x | A | N/A | | | function scope of f ========================================= Ordinary | Members ? | Tags | Labels ----------------------------------------- N/A | N/A | N/A | | | | block scope
And the hierarchy of the region is โblock region No. 1โ โ โscope of the function fโ โ โscopeโ.
I once spoke to a C compiler writer, and he said that x not in any area. Can someone explain how this will work? How can we refer to x at all? Further quote (underline mine):
An identifier may indicate an object; function; tag or member of a structure, union, or enumeration; typedef name; label name macro name or macro parameter.
The same identifier can denote different objects at different points in the program.
For every other object that is indicated by an identifier, the identifier is visible (i.e., can be used) only in the area of โโthe program text, called its area.
If we say that a member of the structure does not have a scope, then it is not visible and therefore cannot be used. But, obviously, we can use the elements of the structure. Did I miss something?