User manual
196
mikoC PRO for dsPIC
MikroElektronika
Lvalues
Lvalue is an object locator: an expression that designates an object. An example of lvalue expression is *P, where P is
any expression evaluating to a non-null pointer. A modiable lvalue is an identier or expression that relates to an object
that can be accessed and legally changed in memory. A const pointer to a constant, for example, is not a modiable
lvalue. A pointer to a constant can be changed (but its dereferenced value cannot).
Historically, l stood for “left”, meaning that lvalue could legally stand on the left (the receiving end) of an assignment
statement. Now only modiable lvalues can legally stand to the left of an assignment operator. For example, if a and
b are nonconstant integer identiers with properly allocated memory storage, they are both modiable lvalues, and
assignments such as a = 1 and b = a + b are legal.
Rvalues
The expression a + b is not lvalue: a + b = a is illegal because the expression on the left is not related to an object.
Such expressions are sometimes called rvalues (short for right values).
Scope and Visibility
Scope
The scope of an identier is a part of the program in which the identier can be used to access its object. There are
different categories of scope: block (or local), function, function prototype, and le. These categories depend on how
and where identiers are declared.
- Block: The scope of an identier with block (or local) scope starts at the declaration point and ends at
the end of the block containing the declaration (such block is known as the enclosing block). Parameter
declarations with a function denition also have block scope, limited to the scope of the function body.
- File: File scope identiers, also known as globals, are declared outside of all blocks; their scope is from the
point of declaration to the end of the source le.
- Function: The only identiers having function scope are statement labels. Label names can be used with
goto statements anywhere in the function in which the label is declared. Labels are declared implicitly by
writing label_name: followed by a statement. Label names must be unique within a function.
- Function prototype: Identiers declared within the list of parameter declarations in a function prototype
(not as a part of a function denition) have a function prototype scope. This scope ends at the end of the
function prototype.
Visibility
The visibility of an identier is a region of the program source code from which an identier’s associated object can be
legally accessed.
Scope and visibility usually coincide, though there are circumstances under which an object becomes temporarily
hidden by the appearance of a duplicate identier: the object still exists but the original identier cannot be used to
access it until the scope of the duplicate identier ends.