HP C Programmer's Guide (92434-90009)

48 Chapter3
Calling Other Languages
Comparing HP C and HP Pascal
9. A union corresponds directly to an untagged HP Pascal variant record. For example, the
HP C union:
typedef union {
int i;
float r;
unsigned char c;
} UNIONTYPE;
corresponds to:
TYPE
UNIONTYPE = RECORD CASE INTEGER OF
1 : (i : INTEGER);
2 : (r : REAL);
3 : (c : CHAR);
END;
The tagged HP Pascal variant record:
TYPE
TAGGED_UNIONTYPE = RECORD CASE tag : INTEGER OF
1 : (i : INTEGER);
2 : (r : REAL);
END;
corresponds to this HP C structure:
typedef struct {
int tag;
union {
int i;
float r;
};
} TAGGED_UNIONTYPE;
10.HP Pascal subranges with a negative value as their lower bound have enough bits
allocated to contain the upper bound, with an extra bit for the sign. Thus, the HP C
structure:
typedef struct {
int b1 : 1;
int b2 : 2;
int b3 : 3;
int b4 : 4;
int b5 : 5;
int b6 : 6;
int b7 : 7;
} BITS;
corresponds to the following untagged HP Pascal record:
TYPE
BITS = PACKED RECORD
b1 : BOOLEAN;
b2:-2.. 1;
b3:-4.. 3;
b4:-8.. 7;