HP C Programmer's Guide (92434-90009)

160 Chapter6
Migrating C Programs to HP-UX
Migrating an Application
Migrating an Application
Following are the general steps to migrate a C program from an HP-UX or UNIX system.
1. Test your program on the current system so you have a copy of the results.
2. Use the tar command (see the HP-UX Reference manual) with the cv options to
transfer the source files you want to migrate to tape.
3. Use the tar command with the r option to transfer any associated data files to tape.
4. Install the source files and any related data files on the HP 9000 Series 700/800 using
the tar command with the x option.
5. Check your makefiles for any implementation-specific options. Change programs
depending on implementation-specific command options. On HP-UX systems, these
options are generally preceded by -W or +, and may include options to be passed to ld or
cpp. You can optionally include the -g option to permit symbolic debugging.
6. Review the lists of "Guidelines for Portability" and "Practices to Avoid" in the previous
chapter and check over the source code for system-dependent programming. (If the
source files are extensive, you may want to skip this step and catch errors when you run
lint or compile.)
7. Search for instances of #include files and make sure that the files or routines included
appear in the correct directory or library on the HP 9000 Series 700/800 computer.
8. Run lint, a C program checker that verifies source code and prints warning messages
about problems with the source code style, efficiency, portability, and consistency.
9. Compile the program on the HP 9000 Series 700/800 computer using the cc command.
(Refer to the HP C/HP-UX Reference Manual for details about the cc command and
options, and explanations of error, warning, and panic messages.) Change the source
code to resolve any messages you receive.
10.Recompile the program until you receive no messages.
11.Link the program. The linker reports any symbols that cannot be found.
12.Run the program on the HP 9000 Series 700/800 computer. Compare the results with
those received on the original computer.
Byte Order
The VAX computer has a different byte order from HP 9000 computers. Binary data files
created on a VAX computer may need to be swapped before they can be interpreted on an
HP 9000 Series 700/800 computer. Use the descriptions of storage and alignment on both
systems to write a programming tool to reorder the data. The C library function swab (see
the HP-UX Reference Manual) can be used to swap bytes, if that is sufficient for the
particular application. Otherwise, you need to write a customized tool. ASCII code and