TNS/R Native Application Migration Guide

C and C++ Migration Tasks
TNS/R Native Application Migration Guide523745-001
3-6
Converting Code to Use 32-Bit Pointers and Integers
Converting Code to Use 32-Bit Pointers and
Integers
The memory model determines the size of pointers. In the TNS C environment, there
are two memory models: the small-memory model (16-bit pointers) and the large-
memory model (32-bit pointers).
The data model determines the size of type int. In the TNS C and C++ environments,
there are two data models: the 16-bit data model and the 32-bit (or wide) data model.
In the native C and C++ environments, there are only the large-memory model and the
32-bit data model.
You must convert existing Guardian C programs that use the small-memory model to
the large-memory model. You must also convert existing Guardian C and C++
programs that use the 16-bit data model to the 32-bit data model. (You do not need to
convert existing OSS C and C++ programs because OSS only supports the large-
memory model and the 32-bit data model.)
The memory and data models a program uses are determined by the environment in
which you run the compiler (Guardian or OSS), the version of the compiler, the
SYSTYPE pragma setting, and the explicit XMEM, NOXMEM, WIDE, or NOWIDE pragmas
in the source code. D-series versions of the Guardian TNS C compiler and D20
versions of the Guardian C++ preprocessor generate programs that use the large-
memory model and the 16-bit data model by default. See the C/C++ Programmer’s
Guide for further details.
Before compiling small-memory model or 16-bit data model programs with the native
compilers, it is often easier to first convert them to the large-memory model and 32-bit
data model using the TNS C compiler. The following list provides guidelines for using
the TNS C compiler to convert programs to the large-memory model and the 32-bit
data model.
Specify the XMEM and WIDE pragmas in your source code.
Compile your program using the TNS C compiler with the STRICT pragma.
Ensure that the type of a function call argument matches the defined type of its
associated parameter. The TNS C compiler issues the following warning message
for argument-parameter mismatches:
Warning 86: argument "name" conflicts with formal definition
Write function prototypes for all user-written functions without prototypes. The TNS
C compiler issues the following warning message for function calls without
corresponding function prototypes:
Warning 95: prototype function declaration not in scope:
"function-name"