C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Running and Debugging C and C++ Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
19-9
Two Data Models: 16-Bit and 32-Bit
The stack, global, and static aggregates that have been specified with the NOXVAR
pragma and global and static scalars are stored in the user data segment. The user
data segment is limited to a total of 64 KB.
Buffers that are used in certain Guardian system procedure calls must be stored in the
user data segment so that they will be 16-bit addressable. See the description of
pragma XVAR on page 13-117, for a discussion of the XVAR and NOXVAR pragmas and
how to use them to specify whether global and static aggregates are stored in the
extended segment or the user data segment.
Two Data Models: 16-Bit and 32-Bit
HP TNS C and TNS C++ have two data models: the 16-bit data model and the 32-bit
data model. HP native C and native C++ have only the 32-bit data model. (The 32-bit
data model is also referred to as the wide-data model.)
The data model determines the size of the type int. You cannot mix modules
compiled with different data models; all modules in a program must be compiled for
either the 16-bit data model or the 32-bit data model.
Table 19-3 summarizes the characteristics of each data model.
For portability and compatibility with other C environments, HP strongly recommends
that you write programs using the 32-bit data model. For conversion details, see
Converting Programs to the 32-Bit Data Model on page 19-11.
Selecting Memory and Data Models
This topic applies only to TNS C and C++ programs. Native C and C++ programs use
one memory model and one data model.
In the Guardian environment, you can select from the small-memory or large-memory
model and the 16-bit or 32-bit data model. In the OSS environment, only the large-
memory model and 32-bit data model are available.
For portability and compatibility with other C environments, HP strongly recommends
that you write your programs using the large-memory model and the 32-bit data model.
Table 19-4 on page 19-10 summarizes the relationship between memory models and
data models.
Table 19-3. Data Models
Data Model Size of Type int Available in
16-bit 16 bits Guardian environment for TNS C and
C++ programs only
32-bit or wide 32 bits Guardian and OSS environments for all C
and C++ programs