Name Spaces


At any point in the source code, there will be a number of different identifiers that are "in scope", i.e. visible. The same identifier name can be used for different purposes within the same scope providing the identifiers are in different name spaces.

Four name spaces are defined in the C language:

  1. Ordinary identifiers, i.e objects, functions, typedef names and enum constants
  2. Tags of structures, unions and enumerations
  3. Members of each structure
  4. Label names

This means for example that:

If these rules are violated, QA C and indeed any compiler, will generate an error warning. It is permissible within the rules of C to use the same identifier for more than one purpose providing the name spaces are respected; but it is usually unwise to do so and programming guidelines often specifically prohibit this sort of thing, e.g.:

Note that macro identifiers are not part of any name space, because they are a preprocessor feature only and are not subject to the same rules of scope.

Index