Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ User's Guide - the "data threshold" option is used to set the maximum size for data objects http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
The "data threshold" option is used to set the maximum size for data objects
to be included in the default data segment.  This option can be used with
the compact, large, and huge (16-bit) memory models only.  These are memory
models where there can be more than one data segment.  Normally, all data
objects whose size is less than or equal to the threshold value are placed
in the default data segment "_DATA" unless they are specifically declared to
be far items.  When there is a large amount of static data, it is often
useful to set the data threshold size so that all objects larger than this
size are placed in another (far) data segment.  For example, the option
"zt100" causes all data objects larger than 100 bytes in size to be
implicitly declared as far and grouped in other data segments.
The default data threshold value is 32767.  Thus, by default, all objects
greater than 32767 bytes in size are implicitly declared as far and will be
placed in other data segments.  If the "zt" option is specified without a
size, the data threshold value is 256.  The largest value that can be
specified is 32767 (a larger value will result in 256 being selected).

If the "zt" option is used to compile any module in a program, then you must
compile all the other modules in the program with the same option (and
value).

Care must be exercised when declaring the size of objects in different
modules.  Consider the following declarations in two different C files.
 Suppose we define an array in one module as follows:


     extern int Array[100] = { 0 };

and, suppose we reference the same array in another module as follows:


     extern int Array[10];

Assuming that these modules were compiled with the option "zt100", we would
have a problem.  In the first module, the array would be placed in another
segment since Array[100] is bigger than the data threshold.  In the second
module, the array would be placed in the default data segment since
Array[10] is smaller than the data threshold.  The extra code required to
reference the object in another data segment would not be generated.

Note that this problem can also occur even when the "zt" option is not used
(i.e., for objects greater than 32767 bytes in size).  There are two
solutions to this problem:  (1) be consistent when declaring an object's
size, or, (2) do not specify the size in data reference declarations.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson