Different entities may have the same identifier if they have different scopes or are in different name spaces1. In the case of int main() { static int main; … }
, the first main
has file scope, and the second main
has block scope.
At any particular point, only one identifier is visible in a name space. In GetSize(GetSize)
, only the static GetSize
is visible. It hides the int GetSize(int)
, so the function GetSize
is not visible. Thus, this code gets an error.
An identifier declared at file scope with static
has internal linkage. An object identifier declared at block scope without extern
(including those that have static
) has no linkage. Because these identifiers do not have external linkage, they never need to be known outside the current translation unit. Therefore, these identifiers do not need to appear in object files: There is no need for them to have names visible to the linker. They are typically accessed by code generated by the compiler during compilation of the translation unit, and this code addresses objects numerically (by location in memory), not by name.
Many C implementations provide debugging facilities. Debuggers generally need to know the names of things even if they have internal or no linkage. In these cases, the C implementation may use any scheme it desires to record information about names.
1 The name spaces of C are: label names; tags of structures, unions and enumerations; members of structures or unions (a separate space for each structure or union); and all other identifiers. The standard also refers to a name space for macro names.