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

The C compiler running in the OSS environment supports only the large-memory model and ILP32
data model.
The memory model and data model selected determines the model-dependent library file that you
bind into a program. For more details, see Chapter 14: Compiling, Binding, and Accelerating
TNS C Programs, and Chapter 15: Compiling, Binding, and Accelerating TNS C++ Programs.
Converting Programs to the ILP32 Data Model
HP strongly recommends that you convert your TNS C and C++ programs from the 16-bit data
model to the ILP32 (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 ILP32 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 ILP32 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, TCP/IP sockets library functions,
and Guardian system procedures might require type int.
Debugging C and C++ Programs
To debug C and C++ programs, you can use several debuggers:
Debug on TNS/R systems
Inspect on TNS/R or TNS/E systems
Native Inspect on TNS/E systems and from within NSDEE on the PC
The Visual Inspect debugger
326 Running and Debugging C and C++ Programs