User manual
mikroC PRO for dsPIC
MikroElektronika
197
Technically, visibility cannot exceed a scope, but a scope can exceed visibility. See the following example:
void f (int i) {
int j; // auto by default
j = 3; // int i and j are in scope and visible
{ // nested block
double j; // j is local name in the nested block
j = 0.1; // i and double j are visible;
// int j = 3 in scope but hidden
}
// double j out of scope
j += 1; // int j visible and = 4
}
// i and j are both out of scope
Name Spaces
Name space is a scope within which an identier must be unique. The mikroC PRO for dsPIC30/33 and PIC24 uses
four distinct categories of identiers:
1. goto label names - must be unique within the function in which they are declared.
2. Structure, union, and enumeration tags - must be unique within the block in which they are dened. Tags
declared outside of any function must be unique.
3. Structure and union member names - must be unique within the structure or union in which they are
dened. There is no restriction on the type or offset of members with the same member name in different
structures.
4. Variables, typedefs, functions, and enumeration members - must be unique within the scope in which they
are dened. Externally declared identiers must be unique among externally declared variables.
Duplicate names are legal for different name spaces regardless of the scope rules.
For example:
int blue = 73;
{ // open a block
enum colors { black, red, green, blue, violet, white } c;
/* enumerator blue = 3 now hides outer declaration of int blue */
struct colors { int i, j; }; // ILLEGAL: colors duplicate tag
double red = 2; // ILLEGAL: redenition of red
}
blue = 37; // back in int blue scope