mikroC - C Compiler for Microchip PIC microcontrollers
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;
int i;
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
izers. Each of the variables is declared to be of
int
the default
volatile
Here is an example of variable declaration:
/* Create 3 integer variables called x, y, and z and
int x = 1, y = 2, z;
These are all defining declarations; storage is allocated and any optional initializ-
ers are applied.
page
86
/* Definition of variable i */
/* Error: i is already defined! */
,
,... are any sequence of distinct identifiers with optional initial-
var1
var2
. Specifier
storage-class
. Optional
auto
. For more details, refer to Storage Classes and Type Qualifiers.
initialize x and y to the values 1 and 2, respectively: */
MikroElektronika: Development tools - Books - Compilers
type
can take values
extern
can take values
type-qualifier
// z remains uninitialized
making it simple...
; if omitted,
defaults to
type
,
,
static
register
or
const
mikroC
, or
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?