TNS/E Native Application Conversion Guide
C and C++ Conversion Tasks
TNS/E Native Application Conversion Guide—529659-003
3-3
Converting Code to Use 32-Bit Pointers and Integers
TNS/R code cannot be executed on a TNS/E platform, and TNS/E code cannot be
executed on a TNS/R platform.
For c89 and c99 conversion information, see Section 11, OSS API and Utilities
Conversion Tasks.
All code generated by the TNS/E native compilers is position-independent code (PIC).
PIC is code that need not be modified to run at different virtual addresses and is used
to create dynamic-link libraries (DLLs).
For details on compiling and linking native C and C++ programs, see the
C/C++
Programmer’s Guide
.
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 supports only 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. Follow these guidelines for doing the
conversion:
•
Specify the XMEM and WIDE pragmas in your source code.
•
Use the TNS C compiler with the STRICT pragma.










