User manual
226
mikoC PRO for dsPIC
MikroElektronika
Declarations and Declarators
The declaration contains specier(s) followed by one or more identiers (declarators). The declaration begins with
optional storage class speciers, type speciers, and other modiers. The identiers are separated by commas and the
list is terminated by a semicolon.
Declarations of variable identiers have the following pattern:
storage-class [type-qualier] type var1 [=init1], var2 [=init2], ... ;
where var1, var2,... are any sequence of distinct identiers with optional initializers. Each of the variables is
declared to be of type; if omitted, type defaults to int. The specier storage-class can take the values extern,
static, register, or the default auto. Optional type-qualier can take values const or volatile. For
more details, refer to Storage Classes and Type Qualiers.
For example:
/* Create 3 integer variables called x, y, and z
and initialize x and y to the values 1 and 2, respectively: */
int x = 1, y = 2, z; // z remains uninitialized
/* Create a oating-point variable q with static modier,
and initialize it to 0.25: */
static oat q = .25;
These are all dening declarations; storage is allocated and any optional initializers are applied.
Linkage
An executable program is usually created by compiling several independent translation units, then linking the resulting
object les with preexisting libraries. A term translation unit refers to a source code le together with any included les,
but without the source lines omitted by conditional preprocessor directives. A problem arises when the same identier
is declared in different scopes (for example, in different les), or declared more than once in the same scope.
The linkage is a process that allows each instance of an identier to be associated correctly with one particular object
or function. All identiers have one of two linkage attributes, closely related to their scope: external linkage or internal
linkage. These attributes are determined by the placement and format of your declarations, together with an explicit (or
implicit by default) use of the storage class specier static or extern.
Each instance of a particular identier with external linkage represents the same object or function throughout the entire
set of les and libraries making up the program. Each instance of a particular identier with internal linkage represents
the same object or function within one le only.