TNS/E Native Application Conversion Guide

C and C++ Conversion Tasks
TNS/E Native Application Conversion Guide529659-003
3-4
Converting Code to Use 32-Bit Pointers and Integers
Ensure that the type of a function call argument matches the defined type of its
associated parameter. The TNS C 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 without prototypes. The TNS
C compiler issues this warning message for function calls without 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
TNS C 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 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 and pTAL procedures.
Ensure that literals do not cause type mismatches, as illustrated in this example:
#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. Declarations in the cextdecs header file
do 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.