Coding and general discussion relating to the compiler
Moderators: David Barker, Jerry Messina
-
Jerry Messina
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Post
by Jerry Messina » Tue Feb 19, 2013 11:23 am
The clear() function seems to get confused sometimes when used with aliases...
Code: Select all
// this struct is 133 bytes total
public structure tdata_block_packet_t
cmd as byte
len as byte
block_no as word
b(128) as byte // 128 byte data buffer
eop as byte
end structure
public structure cmd_packet_t
tblock as tdata_block_packet_t
end structure
public dim packet as cmd_packet_t
// create an alias for the 128-byte packet tblock data buffer 'b(128)'
dim rxb as packet.tblock.b
// now, these next two statements should do the same thing
// this clears 128 bytes (correct)
clear (packet.tblock.b)
// this clears 133 bytes (incorrect)
// it starts at the proper address, but has the length wrong
clear(rxb)
This should work, shouldn't it?
-
David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
-
Contact:
Post
by David Barker » Tue Feb 19, 2013 1:07 pm
Yes, it should work but clearly doesn't. I've uploaded a new BETA (B21) at the usual location. This will fix the problem.
It's a rather more difficult fix than the problem looks. Please let me know if B21 has side effects with any of your other programs.
-
Jerry Messina
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
Post
by Jerry Messina » Tue Feb 19, 2013 7:43 pm
>It's a rather more difficult fix than the problem looks
I can imagine. The actual code is more complex than the simple test case, and B21 worked with it. I ran a few other things through it and it didn't seem to cause any ill effects.
Thanks.
-
David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
-
Contact:
Post
by David Barker » Tue Feb 19, 2013 7:58 pm
It also impacted on SizeOf(), which should also now work OK.