נסיון שלי לעזור...
להלן הפסקה הרלוונטית מתוך ה-Appendix A: Reference Manual שך הספר The C Programming Language של Brian W. Kernighan ו-Dennis M. Ritchie:
A11. Scope and Linkage A program need not all be compiled at one time: the source text may be kept in several files containing tranlation units, and precompiled routines may be loaded from libraries. Communcation among the functions of a program may be carried out both through calls and through manipulation of external data. Therefore, there are two kinds of scope to consider: first, the lexical scope of an identifier, which is the region of the program text within which the identifier's chracteristics are understood; and second, the scope associated with objects and functions with external linkage, which determines the connections between identifiers in separately compiled translation units. A11.1 Lexical Scope Identifiers fall into several name spaces that do not interfere with one another; the same identifier may be used for different purposes, even in the same scope, if the uses are in different name spaces. These classes are: objects, functions, typedef names, and enum constants; labels; tags of structures, unions, and enumerations; and members of each structure of union individually. The lexical scope of an object or function identifier in an external declaration begins at the end of its declarator and persists to the end of the translation unit in which it appears. The scope of a parameter of a function definition begins at the start of the block defining the function, and persists through the function; the scope of a parameter in a function declaration ends at the end of the declarator. The scope of an identifier declared at the head of a block begins at the end of its declarator, and persists to the end of the block. The scope of a label is the whole of the function in which it appears. The scope of a structure, union or enumeration tag, or an enumeration constant, begins at its appearance in a type specifier, and persists to the end of the translation unit (for declarations at the external level) or to the end of the block (for declarations within a function). If an identifier is explicitly declared at the head of a block, including the block constituting a function, any declaration of the identifier outside the block is suspended until the end of the block. A11.2 Linkage Within a translation unit, all declarations of the same object or function identifier with internal linkage refer to the same thing, and the object or function is unique to that translation unit. All declarations for the same object of function identifier with external linkage refer to the same thing, and the object or function is shared by the entire program. As discussed in section A10.2, the first external declaration for an identifier gives the identifier internal linkage if the static specifier is used, external linkage otherwise. If a declaration for an identifier within a block does not include the extern specifier, then the identifier has no linkage and is unique to the function. If it does include extern, and an external declaration for the identifier is active in the scope surrounding the block, then the identifier has the same linkage as the external declaration, and refers to the same object or function; but if no external declaration is visible, its linkage is external.
נראה לי שהחלק הרלוונטי עבורך הוא A11.1... בכל מקרה, הנה התשובה לדוגמא שלך:
{ // A block (normal of body of a function). // a is not recognised here. int a; // a is recognised here. We will call it a1. { // a is linked to a1. int a; // overriding of a1 with what we'll call a2. // Now a is linked to a2. } } // Now a is linked to a1. // a is not recognised here at all. { int a; // a is recognised. We will cal it a3. // a is linked to a3. } // Again, a is not recognised here. { int a; // a is recognised again. We will call it a4. // a is linked to a4. }
מקווה שזה היה מובן
. מקווה שעזרתי, אהד.