issue with comparing structures
Posted: Fri Jun 17, 2016 3:17 pm
It seems the compiler is getting structure compare operations wrong.
When comparing two structures it only seems to work for sizes of 1, 2, or 4 bytes
When comparing two structures it only seems to work for sizes of 1, 2, or 4 bytes
Code: Select all
// SF 2.2.2.5 or SF 2.2.2.5 BETA 6, ICC 1164
//
// define number of bytes in the struct
// for STRUCT_SIZE = 1, 2, or 4 the comparison works ok
// for other sizes it only compares the first two bytes
// doesn't matter if the struct contains individual items or an array
const STRUCT_SIZE = 7
structure rtc_time_t
b(STRUCT_SIZE) as byte
end structure
dim t1, t2 as rtc_time_t
dim match as boolean
// 'clear' always gets the structure size correct
clear(t1)
clear(t2)
// structure compare doesn't always compare the correct number of bytes
if (t1 = t2) then
match = true
endif