TNS/R Native Application Migration Guide

C and C++ Migration Tasks
TNS/R Native Application Migration Guide523745-001
3-7
Replacing Obsolete External Function Declarations
Ensure that the formal and actual parameters of pointer types are matched. The
TNS C compiler issues the following 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.
Replacing Obsolete External Function
Declarations
External function declarations declare functions not written in the C language. D-series
TNS C compilers recognize correctly but issue warnings for C-series external function
declaration syntax with D-series replacements. The native compilers do not recognize
the C-series syntax. If you use FUNCTION pragma syntax or declarations with
_language name keywords (such as _tal and _c), no changes are required. See the
C/C++ Programmers Guide for details.