ABL electronic PIC12 Personal Computer User Manual


 
Let’s have an example:
/* Here is a nondefining declaration of function max; */
/* it merely informs compiler that max is a function */
int max();
/* Here is a definition of function max: */
int max(int x, int y) {
return (x>=y) ? x : y;
}
int i;
/* Definition of variable i */
int i;
/* Error: i is already defined! */
Declarations and Declarators
A declaration is a list of names. The names are sometimes referred to as declara-
tors or identifiers. The declaration begins with optional storage class specifiers,
type specifiers, and other modifiers. The identifiers are separated by commas and
the list is terminated by a semicolon.
Declarations of variable identifiers have the following pattern:
storage-class
[
type-qualifier
]
type var1
[=
init1
],
var2
[=
init2
],
...;
where var1, var2,... are any sequence of distinct identifiers with optional initial-
izers. Each of the variables is declared to be of
type
; if omitted,
type
defaults to
int. Specifier
storage-class
can take values extern, static, register, or
the default
auto. Optional
type-qualifier
can take values const or
volatile. For more details, refer to Storage Classes and Type Qualifiers.
Here is an example of variable declaration:
/* 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
These are all defining declarations; storage is allocated and any optional initializ-
ers are applied.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
86
MikroElektronika:
Development
tools
-
Books
-
Compilers
page