On Mon, 5 Aug 2002, Nick Ioffe wrote:
Hi!
I use packed arrays of booleans and need to look for bit set and clear in them.
The arrays are of different sizes, but I cannot use a conformant array.
I've written function Find_First_bit_Set (buff_ptr:pointer, bit_size:integer) : integer;
and then to pass Addr(bit_array) and BitSizeOf(bit_array).
The problem is that for BitSizeOf (packed array of boolean) always returns me 8*SizeOf like in the following case: program tst; var aa : packed array [1..19] of boolean; begin writeln (SizeOf(aa), ' ', BitSizeOf(aa)); end.
the output I get is: 4 32.
what can be wrong?
Perhaps a bug. Since the hardware can't allocate a fraction of a byte "sizeof" is returning the space allocated for aa rather than the size of aa. Trying different sizes of aa here gives a multiple of 2 bytes, which suggests as a work-around you could use some multiple of 16 for your packed array of boolean.
Russ