HP C Programmer's Guide (92434-90009)

136 Chapter5
Programming for Portability
General Portability Considerations
use during the compilation process. These files are normally invisible to you since they are
created and removed automatically. If, however, your system is tightly constrained for file
space these files, which are usually generated on /tmp or /usr/tmp, may exceed space
requirements. By assigning another directory to the TMPDIR environment variable you can
redirect these temporary files. See the cc manual page for details.
Input/Output
Since the C language definition provides no I/O capability, it depends on library routines
supplied by the host system. Data files produced by using the HP-UX calls write(2) or
fwrite(3) should not be expected to be portable between different system implementations.
Byte ordering and structure packing rules will make the bits in the file system-dependent,
even though identical routines are used. When in doubt, move data files using ASCII
representations (as from printf(3)), or write translation utilities that deal with the byte
ordering and alignment differences.
Checking for Standards Compliance
In order to check for standards compliance to a particular standard, you can use the lint
program with one of the following -D options:
-D_XOPEN_SOURCE
-D_POSIX_SOURCE
For example, the command
lint -D_POSIX_SOURCE file.c
checks the source file file.c for compliance with the POSIX standard.
If you have the HP Advise product, you can also check for C standard compliance using the
apex command.