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

10 Converting C-Series TNS Programs to Use the Current
TNS Compiler
This chapter lists the C language-specific changes that you must make to C-series TNS programs
to compile and run them as TNS programs on current systems. Most of these changes were made
to TNS C to make it compliant with the ISO/ANSI C standard. For a description of Guardian-specific
changes, see the Guardian Application Conversion Guide.
NOTE: Do not convert a C-series TNS C program to a current native C program directly. First
convert the program from C-series TNS C to current TNS C and then to native C.
Replace references to the LARGEC, SMALLC, and WIDEC memory-model library files with the
CLARGE, CSMALL, and CWIDE files.
Replace the min and max macros with the _min and _max macros. The behavior of these
macros has not changed.
Make these keyword changes:
Replace cc_status with _cc_status.
Replace lowmem with _lowmem.
Replace extensible with _extensible.
Replace variable with _variable.
Replace tal with _tal.
The current TNS compiler issues a warning message if it finds an old keyword.
Change code that relies on negative integral values being assigned to errno.
The ISO/ANSI C standard specifies that only positive integral values can be assigned to
errno. To conform to this requirement, changes were made in the errnoh header file. If
your C program source explicitly uses a literal defined in errnoh, the changes cause the
code in the object file to be incompatible with the run-time library. For example:
if (errno == ERANGE) {...}
compiles into code dependent upon the value denoted by ERANGE. ERANGE has changed,
so you must recompile this program. However, you need not recompile a program that checks
only that the value of errno is 0 or not equal to 0.
Change code that relies on the type of size_t, the result of the sizeof operator. The type
size_t has changed from type long to type unsigned long. This change applies to the
large-memory model (pragma XMEM) and the 32-bit or wide data model (pragma WIDE).
Change code that uses the result of the sizeof operator for constant operands under the
32-bit or wide data model (pragma WIDE):
For C-series compilers, the sizeof operator returns 2 or 4 for constant operands.
For the current compilers, the sizeof operator returns 4 for all constant operands.
Change the use of type long as a bitfield type under the 32-bit or wide data model to type
int. The ISO/ANSI C standard supports only type int as a bitfield type. However, the
current TNS compiler continues to support bitfields of type short for the large-memory model.
Specify a function prototype within the scope of each call to a function.
The C-series compiler generates an implicit function prototype at the call to a function that
does not have a prototype specified in the scope of the call. This implicit prototyping violates
149