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

The destructors are invoked for global and static variables in C++.
The process is terminated with a certain completion code, depending on what caused
termination.
When your process returns from main() with no return value, your process completes with a
completion code of 0, normal termination.
When your process calls exit() or terminate_program(), your process completes with
normal or abnormal termination, depending on the completion code you assign to the status or
options and completion_code parameters, respectively.
For active backup process pairs, the call to exit() stops both primary and backup processes.
Two Memory Models: Large and Small
HP TNS C has two memory models: the large-memory model and the small-memory model. HP
TNS C++, native C, and native C++ has only the large-memory model.
Both models support large amounts of code, but the large-memory model also supports large
amounts of data. You cannot mix modules compiled with different memory models; all modules in
a program must be compiled for either the small-memory model or the large-memory model.
Table 54 summarizes the characteristics of each memory model. Figure 2: Memory Models illustrates
the memory models.
Table 54 Memory Models
Available inSize of PointerSize of Data
Space
TNS Process Code
Space
Memory
Model
Guardian environment for TNS C programs
only
16-bit64 KB4 MBSmall
Guardian and OSS environments for all C
and C++ programs
32-bit127.5 MB4 MBLarge
NOTE: The maximum code space for TNS/R and TNS/E code (irrespective of language) is
256MB, from 0x70000000 to 0x80000000. Refer to the HP NonStop S-Series Server Description
Manual for a description of how this space is allocated.
HP strongly recommends that your TNS C programs use the large-memory model.
Small-Memory Model
The small-memory model uses 16-bit addressing and stores all data in the user data space, which
can contain up to 64 KB.
The primary global area contains global scalar variables, scalar variables that are local to a
function but are declared as having storage class static, and pointers to global aggregates that
reside in the secondary global area. (A scalar type is a character, an integer, an enumeration, or
a floating point type. An aggregate type is an array or struct.)
The heap area is reserved for dynamic memory. The heap is managed by the calloc(), free(),
malloc(), and realloc() library functions.
The stack area is reserved for the run-time stack. The stack area stores local variables. Its size is
64 KB minus the size of the heap and the global area.
Large-Memory Model
The large-memory model uses 32-bit addressing. It stores the heap and the global and static
aggregates in a single extended memory segment. Here, static aggregate refers to an aggregate
that is declared with the static storage class specifier. Both global and static aggregates have
Two Memory Models: Large and Small 323