mikroC
making it simple...
DURATION
Duration, closely related to storage class, defines the period during which the
declared identifiers have real, physical objects allocated in memory. We also dis-
tinguish between compile-time and run-time objects. Variables, for instance, unlike
typedefs and types, have real memory allocated during run time. There are two
kinds of duration: static and local.
Static Duration
Memory is allocated to objects with static duration as soon as execution is under-
way; this storage allocation lasts until the program terminates. Static duration
objects usually reside in fixed data segments allocated according to the memory
model in force. All globals have static duration. All functions, wherever defined,
are objects with static duration. Other variables can be given static duration by
using the explicit
In mikroC, static duration objects are not initialized to zero (or null) in the absence
of any explicit initializer.
An object can have static duration and local scope – see the example on the fol-
lowing page.
Local Duration
Local duration objects are also known as automatic objects. They are created on
the stack (or in a register) when the enclosing block or function is entered. They
are deallocated when the program exits that block or function. Local duration
objects must be explicitly initialized; otherwise, their contents are unpredictable.
The storage class specifier
ables, but is usually redundant, because
within a block.
An object with local duration also has local scope, because it does not exist out-
side of its enclosing block. The converse is not true: a local scope object can have
static duration.
MikroElektronika: Development tools - Books - Compilers
mikroC - C Compiler for Microchip PIC microcontrollers
or
storage class specifiers.
static
extern
can be used when declaring local duration vari-
auto
auto
is the default for variables declared
page
57
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?