User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
223
Declarations and Declarators
The declaration contains specier(s) followed by one or more identiers (declarators). The declaration begins with
optional storage class speciers, type speciers, and other modiers. The identiers are separated by commas and the
list is terminated by a semicolon.
Declarations of variable identiers have the following pattern:
storage-class [type-qualier] type var1 [=init1], var2 [=init2], ... ;
where var1, var2,... are any sequence of distinct identiers with optional initializers. Each of the variables is
declared to be of type; if omitted, type defaults to int. The specier storage-class can take the values extern,
static, register, or the default auto. Optional type-qualier can take values const or volatile. For
more details, refer to Storage Classes and Type Qualiers.
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 modier,
and initialize it to 0.25: */
static oat q = .25;
These are all dening 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 identier
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 identier to be associated correctly with one particular object
or function. All identiers 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 specier static or extern.
Each instance of a particular identier 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 identier with internal linkage represents
the same object or function within one le only.