problems with the C parser
T.p.
brisco at topaz.RUTGERS.EDU
Fri May 30 07:44:01 AEST 1986
I've been trying to translate a program written in Vax
Pascal to C on our Suns.
My problem arose when I was trying to translate a pascal
variant record structure into a C union structure. The structure type
(in pascal) looked as follows: (keep in mind - both were for 32 bit machines)
newtype = record case selector of
0:(int: unsigned);
1:(bool: packed array [0..31] of boolean);
end
Which I had translated into C as:
typedef union {
int intfield; /* change the record name - keyword */
struct bool{unsigned x[32]:1};
} newtype;
The C parser barfed all over this. I tried every combination
of unsigned x:1[32], ..... that I could think of. Out of frustration
I looked up the syntax of the declarations in K&R and found that the
initial guess had been correct!
I wanted an integer that I could index into by bit, so I could
avoid using masks (which weren't going to be easily used due to the
methodology of the original program).
Am I going crazy or is our C parser brain-damaged? Can anyone
else compile the above structure declaration?
"Wah!"
"No, no. It's 'Wah!'"
"Wah!"
"That's better!"
tp.
More information about the Comp.lang.c
mailing list