Manafacture: HP
File size: 462.75 kb
File name:
|
Other manuals for this model:
manual abstract
Lexical Elements
Identifiers
block scope. At location A, identifier i is declared. Its scope continues until the end of the
block in which it is defined (point G). References to i at location B refer to an integer object.
At point C, another identifier is declared. The previous declaration for i is hidden by the
new declaration until the end of the block in which the new i is declared. References to the
identifier i result in references to a floating-point number (point D). At the end of the
second block (point E), the floating-point declaration of i ends. The previous declaration of
i again becomes visible, and references to identifier i at point F reference an int.
Storage Duration
Identifiers that represent variables have a real existence at runtime, unlike identifiers
that represent abstractions like typedef names or structure tags. The duration of an
object's existence is the period of time in which the object has storage allocated for it.
There are two different durations for C objects:
1. Static — An object whose identifier is declared with external or internal linkage, or
with the storage-class specifier static, has static storage duration. Objects with static
storage duration have storage allocated to them when the program begins execution.
The storage remains allocated until the program terminates.
2. Automatic — An object whose identifier is declared with no linkage, and without the
storage-class specifier static, has automatic storage duration. Objects with automatic
storage duration are allocated when entering a function and deallocated on exit from a
function. If you do not explicitly initialize such an object, its contents when allocated
will be indeterminate. Further, if a block that declares an initialized automatic duration
object is not entered through the top of the block, the object will not be initialized.
Name Spaces
In any given scope, you can use an identifier for only one purpose. An exception to this rule
is caused by separate name spaces. Different name spaces allow the same identifier to be
overloaded within the same scope. This is to say that, in some cases, the compiler can
determine from the context of use which identifier is being referred to. For example, an
identifier can be both a variable name and a structure tag.
Four different name spaces are used in C:
1. Labels — The definition of a label is always followed by a colon ( : ). A label is only
referenced as the object of a goto statement. Labels, therefore, can have the same
spelling as any nonlabel identifier.
2. Tags — Tags are part of structure, union, and enumeration declarations. All tags for
these constructs share the same name space (even though a preceding struct, union
or enum keyword could clarify their use). Tags can have the same spelling as any
non-tag identifier.
3. Members — Each structure or union has its own name space for members. Two
different structures can have members with exactly the same names. Members are
therefore tightly bound to their defining structure. For example, a pointer to structure
of type A cannot reference members from a structure of type B. (You may use unions or
a cast to accomplish this.)
4. Other names — All other names are in the same name space, including variables,
Chapter 2
15
...Other models in this manual:
Software - MPE/iX 6.5 Operating System (462.75 kb)
Software - MPE/iX 7.0 Operating System (462.75 kb)
Software - MPE/iX 7.5 Operating System (462.75 kb)