C/C++ Programmer's Guide (G06.25+)

C and C++ Extensions
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
2-17
Pointer Modifiers
If _near is used to modify a pointer and neither _waddr or _baddr is specified,
then the pointer can contain either a byte address or a TNS word address, as
follows:
The type qualifier extptr is considered obsolete, but TNS C and C++ still support
it for _tal prototypes. Programs that use this feature will not compile with the
native C and C++ compilers.
For TNS only, certain implicit casting of pointers might result in diagnostics.
Table 2-3, Implicit Pointer Casts, lists which implicit conversions cause a warning
or an error. The column on the far left lists the “from” pointer type and the column
headings list the “to” pointer types.
For TNS only, the compiler generates code to perform implicit conversions for all
cases in Table 2-3, Implicit Pointer Casts, marked valid or warning. However, in the
warning cases, the resulting value may lose some information. Explicit casts can
be used to override the implicit casts.
For TNS only, a pointer with a _baddr modifier cannot be used to access any TNS
word-addressed data types. A pointer with a
_waddr modifier cannot be used to
access any byte-addressed data types.
For TNS only, pointer arithmetic can be performed only on pointers that point to the
same address space. The address spaces are user data space and code space.
If Type Pointed To Is Then Pointer Contains
8-bit scalar
*
byte address
greater than an 8-bit scalar
*
TNS word address
void byte address
struct TNS word address
array Pointer is the same as a pointer to
an element of the array.
*
Arithmetic types and pointer types are called scalar types. Integral and floating
types are collectively called arithmetic types.
Table 2-3. Implicit Pointer Casts
From Type
To Type
_far
_near
_waddr
_near
_baddr _cspace _procaddr
_far valid error error warning
**
error
_near _waddr valid valid warning warning
**
error
_near _baddr valid warning valid warning
**
error
_cspace warning
**
warning
**
warning
**
valid error
_procaddr error error error error valid
**
TNS C++ gives an error for these cases.