HP C Programmer's Guide (92434-90009)

152 Chapter5
Programming for Portability
Porting between HP C and VMS C
Each character constant can contain up to four ASCII characters. If it contains fewer, as
is the normal case, it is padded on the left by NULLs. However, only the low order byte
is printed when the %c descriptor is used with printf. Multicharacter character
constants are treated as an overflow condition on Series 300/400 if the numerical value
exceeds 127 (the overflow is silent). In compatibility mode, Series 700/800 detects all
multicharacter character constants as error conditions and reports them at compile
time.
String constants can have a maximum length of 65535 characters in VMS. They are
essentially unlimited on HP-UX.
VMS provides an alternative means of identifying a function as being the main program
by the use of the adjective main program that is placed on the function definition. This
extension is not supported on HP-UX. Both systems support the special meaning of
main(), however.
VMS implicity initializes pointers to 0. HP-UX makes no implicit initialization of
pointers unless they are static, so dereferencing an uninitialized pointer is an
undefined operation on HP-UX.
VMS permits combining type specifiers with typedef names. So, for example:
typedef long t;
unsigned t x;
is permitted on VMS. This is permitted only in compatibility mode on Series 300/400; it
is not allowed in ANSI C mode on any HP-UX system. To accomplish this on Series
700/800, change the typedef to include the type specifier:
typedef unsigned long t;
tx;
Or use a #define:
#define t long
unsigned t x;
Preprocessor Features
VMS supports an unlimited nesting of #includes. HP-UX in compatibility mode
guarantees 35 levels of nesting. HP-UX in ANSI mode guarantees 57 levels of nesting.
The algorithms for searching for #includes differs on the two systems. VMS has two
variables, VAXC$INCLUDE and C$INCLUDE which control the order of searching. HP-UX
follows the usual order of searching found on most implementations of UNIX.
#dictionary and #module are recognized in VMS but not on HP-UX.
The following symbols are predefined in VMS but not on HP-UX: vms, vax, vaxc,
vax11c, vms_version, CC$gfloat, VMS, VAX, VAXC, VAX11C, and VMS_VERSION.
The following symbols are predefined on all HP-UX systems but not in VMS:
_ _
hp9000s300 on Series 300/400
_ _hp9000s700 on Series 700
_ _hp9000s800 on Series 700/800
_ _hppa on Series 700/800