Hi,
I'm working in a project, where I need to compile old pascal code using GPC (beta 20010201).
The code is scattered with variable types, that depends on bit correlations in unions. E.g: ******************************** type INT0_255 = packed 0..255;
BITS = (BIT0,BIT1,BIT2,BIT3, BIT4,BIT5,BIT6,BIT7, BIT8,BIT9,BIT10,BIT11, BIT12,BIT13,BIT14,BIT15);
var VARIABLE1 : record case int16 of 0: (WORD: INTEGER); 1: (MSB: INT0_255; LSB: INT0_255); 2: (BT : set of BITS); end;
********************************* In order for this declaration to function properly, I seem to need the possibility to specify 'BT' to be just 16 bits, and not 32 bits, which seems to be default.
I tried to find out from the manual if this is possible. I found the following passages: "The Extended Pascal features still missing from GPC are ..., set types with variable bounds, ..." and "Planned features: Other types... *sparse sets; sets of arbitrary types ?? ???"
For me, this is pretty deep water, so I won't take offence if you tell me to RTFM, but never the less... My question is this: Can it be done in the latest release (20010623) or should I wait for someone to implement this feature?
Best Regards Sven Jauring
Sven Jauring wrote:
Unfortunately you are probably right, according to the following small program (.. with a maximum of packed)
program test;
type INT0_255 = packed 0..255;
BITS = (BIT0,BIT1,BIT2,BIT3, BIT4,BIT5,BIT6,BIT7, BIT8,BIT9,BIT10,BIT11, BIT12,BIT13,BIT14,BIT15);
INT16 = integer(16); CARD16 = cardinal(16);
var r32 : packed record case int16 of 0: (WORD:cardinal); 1: (WORD1,WORD2: CARD16); 2: (LSB1,MSB1,LSB2,MSB2: INT0_255); 3: (BT1,BT2 : packed set of BITS); end;
b : bits;
begin writeln(SizeOf(r32)); with r32 do begin WORD:=$DEADBEEF; writeln(word2,' ',word1); writeln(msb2,' ',lsb2,' ',msb1,' ',lsb1); for b:=bit15 downto bit0 do if b in bt2 then write('1') else write('0'); for b:=bit15 downto bit0 do if b in bt1 then write('1') else write('0'); writeln; end; end. Size is 8 bytes, bt2 is all zero, out of aligment with the remaining.
Maurice