|
|
HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 5 Programming for Portability Guidelines for Portability |
|
This section lists some things you can do to make your HP C programs more portable.
The following example illustrates some ways to program for portability. In this example, the include files IEEE.h and floatX.h isolate machine-dependent portions of the code. These include files use the #define and typedef mechanisms to define macro constants and type definitions in the main body of the program. The main program fmult.c uses the #ifdef preprocessor command to include floatX.h by default. If the option -D IEEE_FLOAT is passed to the compiler, and subsequently the preprocessor, the program will use the IEEE representation for the structure float_rep rather than a machine-dependent representation. Partial contents of the file IEEE.h:
Partial contents of the file floatX.h:
Partial contents of the file fmult.c:
|
|