HPlogo HP C/HP-UX Programmer's Guide: Workstations and Servers > Chapter 5 Programming for Portability

Porting between HP C and Domain/C

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

All HP-UX and Domain computers have ANSI C compilers. Strictly standard-compliant programs are highly portable between all these architectures.

The following Domain/C extensions are not supported on HP-UX in compatibility mode and in most cases, are not supported in ANSI mode either:

  • Reference variables.

  • The following preprocessor directives: #attribute, #options, #section, #module, #debug, #eject, #list, #nolist, and #systype.

  • std_$call.

  • __attribute modifier and __options specifier.

  • systype predefined macro.

  • _BFMT__COFF predefined macro.

  • _ISP__M68K predefined macro.

  • _ISP__A88K predefined macro.

  • _ISP__PA_RISC predefined macro.

  • Partial specification of struct and union members.

Function prototypes, struct and union initialization, and the predefined names __DATE__ and __TIME__, all of which are ANSI C features, are supported on HP-UX in ANSI mode.

Compile line options are different between HP-UX C and Domain/C. Check the respective cc(1) page for complete descriptions.

There are other differences between HP-UX C and Domain/C:

  • Alignment: All Domain workstations have hardware or software assists to handle misaligned data. Programs that rely on these features will not run on the Series 800.

  • Floating-point exceptions: All Domain workstations, by default, enable invalid operation, divide by zero, and overflow exception traps. Programs that rely on fault detection, for instance, to enter a fault handler or to terminate execution on encountering a fault, will ordinarily generate useless output on HP-UX. However, the PA1.1 math library for the workstations and servers provides a function fpsetdefaults(3M), which enables these traps and therefore allows such programs to run as expected. For more information, see the HP-UX Floating-Point Guide.

  • struct layout and alignment, especially bit-field, is different.

  • float data type: Domain/C optimizes a statement all of whose atoms are float or floating-point constants, to be evaluated in float rather than double.

  • register declarations: Domain/C completely ignores register declarations, except to ensure that language constraints are not violated.

  • Include file search rules are different.

  • Programs that rely on undefined behaviors, for instance, the order of expression evaluation and the application of unsequenced side-effects, will probably execute differently.

© Hewlett-Packard Development Company, L.P.