The syntax of C is well defined as a result of
the efforts of the ANSI X3J11 Technical Committee. The standard
C function libraries are rich with features that isolate programs
from operating system specific function calls. These factors make
C programs highly portable between various combinations of hardware
platforms and operating systems.
The C programming language was first described in The
C Programming Language, by Brian Kernighan and Dennis
Ritchie. This original language definition has proven powerful enough
to provide the functionality that programmers need. The HP C compiler
supports this language definition, including some Berkeley Software
Distribution (BSD) extensions.
S.C. Johnson developed the Portable C Compiler (pcc) that
became available on a wide range of systems, including the VAX and
the HP 9000 Series 300/400 computers. The syntax and semantics of
HP C are closely compatible with those of pcc.
In December, 1989, the American National Standards Institute
(ANSI) approved a standard for the C programming language. The ANSI
standard clarified a number of areas that were ambiguous and tended
to vary among C compilers. It gave full specifications for the required
library and codified a number of extensions that have been added
to C over the years. (ANSI mode first became available with release
7.0 on the Series 800, release 7.40 on Series 300/400, and release
8.05 on Series 700. Compatibility mode supports the C syntax and
semantics of previous releases.)
The ANSI standard specifies which aspects of C are required
to work the same on conforming implementations, and which can work
differently. Since many ANSI-conforming compilers are available
on a wide variety of platforms, it is easy to develop portable programs.
HP C, when invoked in ANSI mode and used with the preprocessor (cpp),
headers, libraries, and linker, conforms fully with the standard.
Portable C programs are clear, reliable, and easily maintainable
and can be easily transported from one machine to another. With
few modifications, C programs written with portability in mind can
be recompiled and run on different computers. For specific information
on system dependencies, refer to the HP C/HP-UX Reference
Manual.
The ANSI C standard document American National
Standard for Information Systems - Programming Language C, ANSI/ISO
9899-1990 contains complete details on the language
including an appendix with a comprehensive list of portability issues.
This document is available from ANSI at 11 West 42nd Street, New
York City, New York, 10036, telephone (212) 642-4900.
This chapter discusses some guidelines for making your C programs
more portable. Emphasis is placed on HP C specific portability issues,
especially as they relate to porting from pre-ANSI mode HP C (Kernighan
and Ritchie plus BSD extensions) to ANSI mode HP C.