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

Table Of Contents
Introduction to HP C and C++ for NonStop Systems
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
1-22
Porting Programs to HP C and C++ for NonStop
Systems
Horton, Mark. Portable C Software. Prentice Hall, Inc., 1990.
Jaeschke, Rex. Portability and the C Language. Hayden Books, 1989.
Lapin, J. E. Portable C and UNIX System Programming. Rabbit Software, 1987.
Rabinowitz, Henry, and Chaim Schaap. Portable C. Prentice Hall, Inc., 1989.
Porting Programs to HP C and C++ for
NonStop Systems
HP C complies with the ISO/ANSI C standard. Any C program that strictly conforms
with this standard and does not use features beyond this standard can immediately be
compiled in HP C. Programs written in Common-Usage C (also called Kernighan and
Ritchie C or K&R C) can also be compiled with the native C compiler.
For more details on porting UNIX C and C++ programs to Open System Services, see
the Open System Services Porting Guide.
It is impossible to provide a complete set of guidelines on porting programs to
ISO/ANSI C, but most porting issues have one of two solutions:
Replace nonstandard function calls with one or more functions from the ISO/ANSI
C standard. In the OSS environment, you can also use many function calls defined
in the POSIX.1 and POSIX.2 standards and the XPG4 specification.
Redesign the code to use functions and features of ISO/ANSI C.
Many UNIX compilers now comply with the ISO/ANSI C standard. Unlike the HP C
compilers, most of these compilers do not strictly enforce the standard by default.
These compilers allow features that do not comply with the standard but that the
compilers can still process correctly. Therefore, many programs that you thought to be
compliant are not.
To compile standard-compliant programs with the native C compiler, specify the
pragma KR (for Kernighan & Ritchie or Common-Usage C). To compile such programs
with the TNS C compiler, first convert the programs to ISO/ANSI C in their original
environment. The documentation for these compilers often describes the specific
changes required to make a program comply with ISO/ANSI C.
These commercially available texts describe writing programs that comply with the
ISO/ANSI C standard and porting from Common-Usage C to ISO/ANSI C:
Harbison, Samuel P. and Guy L. Steele. C, A Reference Manual. Prentice Hall,
Inc., 1991.
Kernighan, Brian W. and Dennis M. Ritchie. The C Programming Language.
Prentice Hall, Inc., 1988.
Strake, David. C Style: Standards and Guidelines. Prentice Hall, Inc., 1992.
ANSI C Transition Guide. Prentice Hall, Inc., 1990.