HP C Programmer's Guide (92434-90009)

Chapter 3 49
Calling Other Languages
Comparing HP C and HP Pascal
b5 : -16 .. 15;
b6 : -32 .. 31;
b7 : -64 .. 63;
END;
11.Unsigned bit-fields map onto HP Pascal packed record fields whose types are the
appropriate subranges. For example, the HP C structure:
typedef struct {
unsigned int b1 : 1;
unsigned int b2 : 2;
unsigned int b3 : 3;
unsigned int b4 : 4;
unsigned int b5 : 5;
unsigned int b6 : 6;
unsigned int b7 : 7;
} BITS;
corresponds to this untagged HP Pascal record:
TYPE
BITS = PACKED RECORD
b1:0.. 1;
b2:0.. 3;
b3:0.. 7;
b4:0.. 15;
b5:0.. 31;
b6:0.. 63;
b7:0..127;
END;
12.The type void, when applied to a function declaration, corresponds to an HP Pascal
procedure.
13.HP Pascal allocates one byte for Boolean variables, and only accesses the rightmost bit
to determine its value. HP Pascal uses a 1 to represent true and zero for false; HP C
interprets any nonzero value as true and interprets zero as false.
14.HP Pascal sets are packed arrays of unsigned bits. For example, given the HP Pascal
set:
TYPE
SET_10 = SET OF 0 .. 9;
VAR s: SET_10;
the corresponding HP C struct would be:
typedef struct {
unsigned int b0 : 1;
unsigned int b1 : 1;
unsigned int b2 : 1;
unsigned int b3 : 1;
unsigned int b4 : 1;
unsigned int b5 : 1;
unsigned int b6 : 1;
unsigned int b7 : 1;
unsigned int b8 : 1;