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

Table Of Contents
C and C++ Extensions
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
2-22
Data Types
Size of Type int
For native C and C++, the data type int is always 32 bits.
For TNS OSS programs, the data type int is always 32 bits. For TNS Guardian
programs, the size of the data type int can be 16 bits or 32 bits, depending on
whether you have specified the 32-bit (wid) data model. To specify the 32-bit (wide)
data model, use the WIDE pragma. The WIDE pragma compiles only under the large-
memory model.
For TNS C, a C program runs under the large-memory model unless you have
specified the NOXMEM pragma.
For TNS C++, a C++ program always runs under the large-memory model. In addition,
the 32-bit (wide) data model is the default specification. If you want the size of the data
type int to be 16 bits, specify the NOWIDE pragma.
Table 2-5 shows the size of the short, int, and long types when you omit or specify
the WIDE pragma in TNS C.
For TNS C and C++, relative sizes of the types short, int, and long depend on
whether you compile the program under the 32-bit (wide) data model.
Without the 32-bit (wide) data model: With the 32-bit (wide) data model:
char < short = int < long char < short < int = long
For application portability and compatibility with native C and C++, use the 32-bit
(wide) data model whenever possible. For more details on the WIDE pragma, see WIDE
on page 13-115. For more details on the 32-bit (wide) data model, see Two Data
Models: 16-Bit and 32-Bit on page 19-9.
Table 2-5. Relationship Between WIDE Pragma and Types short, int, and long
Data Type
Size Without WIDE Pragma
Specified
Size With WIDE Pragma
Specified
short 16 bits 16 bits
int 16 bits 32 bits
long 32 bits 32 bits