English
Language : 

CC78K4 Datasheet, PDF (62/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 3 DECLARATION OF TYPES AND STORAGE CLASSES
3.7 Initialization
Initialization refers to setting a value in an object beforehand. An initializer carries out the initialization of an
object.
Initialization is performed as follows.
object = {initializer list}
An initializer list must contain initializers for the number of objects to be initialized.
All expressions in initializers or an initializer list for objects that have static storage duration and objects that have
an aggregate type or a union type must be specified with constant expressions.
Identifiers that declare block scope but have external or internal linkage cannot be initialized.
(1) Initialization of objects which have a static storage duration
If no attempt is made to initialize an arithmetic type object that has static storage duration, the value of the object
will be implicitly initialized to 0.
Likewise, a pointer type object that has a static storage duration will be initialized to a null pointer constant.
Example
unsigned int gval1;
static int gval2;
void func (void) {
static char aval;
}
/* initialized by 0 */
/* initialized by 0 */
/* initialized by 0 */
(2) Initialization of objects that have an automatic storage duration
The value of an object that has automatic storage duration becomes undefined and will not be guaranteed if it is
not initialized.
Example
void func(void){
char aval;
:
aval = 1;
}
/*undefined at this point */
/* initialized to 1 */
(3) Initialization of character arrays
A character array can be initialized by a char string literal (char string enclosed with “ ”). Likewise, a character
string in which a series of char string literals are contained initializes the individual members or elements of an
array.
In the following example, the array objects “s” and “t” with no type qualifier are defined and the elements of each
array will be initialized by a char string literal.
char s[ ] = “abc”, t[3] = “abc” ;
62
User’s Manual U15556EJ1V0UM