mikroC

mikroC - C Compiler for Microchip PIC microcontrollers

making it simple...

NAME SPACES

Name space is the scope within which an identifier must be unique. C uses four distinct categories of identifiers:

Goto label names

These must be unique within the function in which they are declared.

Structure, union, and enumeration tags

These must be unique within the block in which they are defined. Tags declared outside of any function must be unique.

Structure and union member names

These must be unique within the structure or union in which they are defined. There is no restriction on the type or offset of members with the same member name in different structures.

Variables, typedefs, functions, and enumeration members

These must be unique within the scope in which they are defined. Externally declared identifiers must be unique among externally declared variables.

Duplicate names are legal for different name spaces regardless of scope rules.

For example:

int blue = 73;

{// open a block

enum colors { black, red, green, blue, violet, white } c; /* enumerator blue hides outer declaration of int blue */

struct colors { int i, j; };

// ILLEGAL: colors duplicate tag

double red = 2;

// ILLEGAL: redefinition of red

}

blue = 37; // back in int blue scope

page

 

56

MikroElektronika: Development tools - Books - Compilers