C/C++ Programmer's Guide (G06.25+)
Introduction to HP C and C++ for NonStop Systems
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
1-19
Writing Portable Programs
•
Fault-tolerant programs
You can write fault-tolerant process pairs using the active backup programming
model.
Writing Portable Programs
A portable application is an application designed using open, industry-standard
languages, application program interfaces (APIs), and middleware, such as the C
language and POSIX.1 API. A portable application can be moved between hardware
systems and middleware environments from different vendors. This subsection
provides guidelines for writing portable C programs.
Complying With Standards
Writing programs to international standards enables you to move them between
different hardware and software environments with little effort. Write your C programs
to comply with the ISO/ANSI C standard: ISO/IEC 9899:1990, Programming
Languages–C. For a complete description of ANSI C, see ANSI X3.159.
If you are writing a program to run in the Open System Services (OSS) environment,
you should also comply with the following standards:
•
X/Open Common Applications Environment (CAE) Specification, System Interfaces
and Headers, Issue 4, Version 2, 1994.
•
X/Open Common Applications Environment (CAE) Specification, System Interface
Definitions, Issue 4, Version 2, 1994.
•
ISO/IEC 9945-1:1990, Information Technology—Portable Operating System
Interface (POSIX) — Part 1: System Application Program Interface (API)
[C Language].
•
ISO/IEC DIS 9945-2:1992, Information Technology—Portable Operating System
Interface (POSIX) — Part 2: Shell and Utilities
The OSS environment provides all of the function calls specified in the POSIX.1
standard, and many of the function calls specified in the POSIX.2 standard and the
XPG4 specification. Before using a function that is not part of the ISO/ANSI C
standard, check to make sure that the OSS environment provides that function.
Feature-test macros enable you to check how well a program complies with these
standards. The C header files contain definitions required by the ISO/ANSI C standard,
the POSIX.1 standard, the POSIX.2 standard, the XPG4 specification, and the XPG4.2
specification. You control the visibility of these definitions with feature-test macros. If a
program does not conform to the standard or specification controlled by a feature-test
macro, the compiler issues error and warning messages.