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

Two Data Models: 16-Bit and ILP32
This section applies to TNS C/C++ only.
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 ILP32 data model.
Table 55 summarizes the characteristics of each data model.
Table 55 Data Models
Available inSize of Type intData Model
Guardian environment for TNS C and C++ programs only16 bits16-bit
Guardian and OSS environments for all C and C++
programs
32 bitsILP32 or wide
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
ILP32 Data Model (page 326).
Selecting Memory and Data Models
This section applies to TNS C/C++ only.
In the Guardian environment, you can select from the small-memory or large-memory model and
the 16-bit or ILP32 data model. In the OSS environment, only the large-memory model and ILP32
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 56: Relationship
Between Memory Models and Data Models summarizes the relationship between memory models
and data models.
Table 56 Relationship Between Memory Models and Data Models
Size of Type intSize of PointerC Compiler PragmasData ModelMemory Model
16 bits16-bitNOXMEM, NOWIDE16-bitSmall
32 bits16-bitNot availableILP32 or wideSmall
16 bits32-bitXMEM, NOWIDE16-bitLarge
32 bits32-bitXMEM, WIDEILP32 or wideLarge
NOTE: The small-memory model and the ILP32 data model cannot be selected together.
The default memory and data models used by the C compiler are determined by the environment
in which the C compiler runs and the SYSTYPE pragma setting, as shown in Table 57. (The
SYSTYPE pragma determines whether a program’s target is the NonStop environment.) To change
the default settings, specify any valid combination of the XMEM, NOXMEM, WIDE, and NOWIDE
pragmas.
Table 57 Default Memory and Data Models
Pragma SettingsData ModelMemory ModelSYSTYPE PragmaCompiler Environment
XMEM, NOWIDE16-bitLargeGUARDIANGuardian
XMEM, WIDEILP32LargeOSSGuardian
XMEM, WIDEILP32LargeGUARDIANOSS
XMEM, WIDEILP32LargeOSSOSS
Two Data Models: 16-Bit and ILP32 325