C/C++ Programmer's Guide (G06.25+)

Converting C-Series TNS Programs to Use the
Current TNS Compiler
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
10-2
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 the ISO/ANSI C standard and results in code that is not
portable. The current TNS compiler does not generate these function prototypes
for you.
Change code that is affected by the behavioral changes of the sscanf(),
fflush(), or fcntl() functions:
°
For C-series compilers, sscanf() returns a -1 if no conversion takes place.
For the current compilers, sscanf() returns a 0 if no conversion takes place.
°
For C-series compilers, the fflush() function can flush partial lines if
standard output (stdout) and standard error (stderr) are directed to type
101 EDIT files. For the current compilers, the fflush() function does not
flush partial lines if stdout and stderr are directed to type 101 EDIT files
because these files are shared resources under the CRE.
For the current compilers, to flush partial lines to the stdout and stderr
files, you must either open the files using freopen() or close and reopen the
files using fopen(). In both cases, these files cannot be shared.
°
For C-series compilers, the fcntl() function with the F_GETDTYPE
parameter returns the device type of the file in bits 4 through 9 of the value
returned. It also returns additional information from the Guardian procedure
DEVICEINFO in other bits of the returned value.
For the current compilers, the fcntl() function returns only the device type
information in the value returned. Instead of calling Guardian procedure
DEVICEINFO, fcntl() calls the Guardian procedure FILE_GETINFO_.
Change macros to use a # directive to replace parameters inside a literal string.
For C-series compilers, if a function-like macro has a literal string in its substitution
list, the compiler treats the literal string as a series of tokens. The compiler
searches the literal string for a token matching the macro parameter list. If the
compiler finds a match, it performs the substitution.