ABL electronic PIC16 Personal Computer User Manual


 
Linkage
An executable program is usually created by compiling several independent trans-
lation units, then linking the resulting object files with preexisting libraries. The
term translation unit refers to a source code file together with any included files,
but less any source lines omitted by conditional preprocessor directives. A problem
arises when the same identifier is declared in different scopes (for example, in dif-
ferent files), or declared more than once in the same scope.
Linkage is the process that allows each instance of an identifier to be associated
correctly with one particular object or function. All identifiers have one of two
linkage attributes, closely related to their scope: external linkage or internal link-
age. These attributes are determined by the placement and format of your declara-
tions, together with the explicit (or implicit by default) use of the storage class
specifier
static or extern.
Each instance of a particular identifier with external linkage represents the same
object or function throughout the entire set of files and libraries making up the
program. Each instance of a particular identifier with internal linkage represents
the same object or function within one file only.
Linkage Rules
Local names have internal linkage; same identifier can be used in different files to
signify different objects. Global names have external linkage; identifier signifies
the same object throughout all program files.
If the same identifier appears with both internal and external linkage within the
same file, the identifier will have internal linkage.
Internal Linkage Rules:
1. names having file scope, explicitly declared as
static, have internal linkage,
2. names having file scope, explicitly declared as const and not explicitly,
declared as extern, have internal linkage,
3.
typedef names have internal linkage,
4. enumeration constants have internal linkage .
MikroElektronika:
Development
tools
-
Books
-
Compilers
87
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...