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-11
Converting Programs to the 32-Bit Data Model
Converting Programs to the 32-Bit Data Model
HP strongly recommends that you convert your TNS C and C++ programs from the
16-bit data model to the 32-bit (or wide) data model. The native C and C++ compilers
do not support the 16-bit data model. This list provides guidelines for this conversion
using the TNS C compiler and Cfront:
Compile your program using the STRICT pragma.
Ensure that the type of a function call argument matches the defined type of its
associated parameter. The compiler issues this warning message for argument-
parameter mismatches:
Warning 86: argument "name" conflicts with formal definition
Write function prototypes for all user-written functions that don’t have prototypes.
The compiler issues this warning message for function calls that don’t have
corresponding function prototypes:
Warning 95: prototype function declaration not in scope:
"function-name"
Ensure that the formal and actual parameters of pointer types are matched. The
compiler issues this warning message if pointers do not match:
Warning 30: pointers do not point to same type of object
For example:
int func1(short *);
In the 16-bit data model and the large-memory model, you can pass to func1 a
pointer of type short or int and get the correct results. In the 32-bit data model,
you can pass to func1 only a pointer of type short; a pointer of type int
generates incorrect results.
Parameter mismatch is most often an issue for Guardian system procedures and
external TAL routines.
Ensure that literals do not cause type mismatches.
#include <cextdecs(MONITORCPUS)>
...
short get_cpu_number;
MONITORCPUS(0x8000 >> get_cpu_number);
In the 32-bit data model, if get_cpu_number is equal to zero, an arithmetic
overflow occurs because the compiler generates code to convert an unsigned 32-
bit integer to a 16-bit signed integer. Note that cextdecs does not use the type
unsigned short.
Avoid using the type int in your program, if possible. Use type long or short
instead. However, if you want to keep your program data-model independent, you
cannot avoid using type int completely. For example, C library calls, bit-fields,