|
| mikroC | |
mikroC - C Compiler for Microchip PIC microcontrollers | making it simple... | ||
|
|
|
|
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 declarators 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:
...;
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
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 initializers are applied.
page |
|
86 | MikroElektronika: Development tools - Books - Compilers |
|