Fanuc C-Executer Operating Manual
B-62443EN-3/03E
- 82 -
2.2 Definition of static variables
There are multiple versions of xlink386, which is used in link operation
of the application, and there are the differences between each versions. The
major difference is as follows.
before ver 1.3 The BSS segment is output in the intermediate file of
incremental linking.
after ver 1.5 The BSS segment is not output in the intermediate
file of incremental linking.
(We don't know about ver 1.4. For ver 1.4, assume as same as ver 1.5.)
By this difference, it is necessary to change the coding method of the
application program. Only the definition of the static variables must be
changed. It is not necessary to care especially about the definition of the
static variables if you use the earlier version of xlink386 ver 1.3.
You must care the following rule if you use the later version of xlink386 ver
1.5.
"The static variables must have the initial value."
This prevents that the static variables which have no initial value will be
placed in the incorrect address because they are placed in the BSS segment
automatically and not output to the intermediate file of incremental link.
The static variables which have the initial value are placed in the xxx_DATA
segment, therefore, there are no problems.
If you link the application program which includes the static variables
which have no initial value using the later version of xlink386 ver 1.5,
the segment like FAR_BSS_1\FAR_BSS will be generated. This segment is listed
in the map file (taskall.map) as follows. There are no errors due to this
segment, but the application program is not executed correctly.
(the segment which is generated by the definition of the static variables
which have no initial value.)
TS1_LDT(264) 0847H 1 3 RW 16T 00000000H 00000003H FAR_BSS_1\FAR_BSS
Concretely, define the static variables in the application program as follows.
(Example)
int var_1 = 0 ;
char var_2 = 0 ;
long var_3[10] = { 0 } ;
struct foo var_4 = { 0 } ;
All static variables must have the initial values like this.
The static variables which are mentioned here are both all variables which
are defined outside of any functions and all static variables which are
defined inside of any function. Also all variables which are defined in
"dramver.c" and "sramver.c" file are static variables. (The initial values
are not effective actually to the variables which are defined in "sramver.c"
file in the execution time of the application.)