Andrew Leiper 0 Posted February 1, 2011 Report Share Posted February 1, 2011 Hello again, sourceboost V7.01 PIC18F2525 The if statement in the code below compiles so that s.DeviceAddress is decremented instead of s.NumRxDataBytes. if (--s.NumRxDataBytes) 0010 0601 DECF gbl_s, F 0012 5202 MOVF gbl_s+D'1', F 0014 A4D8 BTFSS STATUS,Z ///////////////////////////////////////////// #include <system.h> typedef struct { unsigned char DeviceAddress; unsigned char NumRxDataBytes; } TTestStruct; TTestStruct s; void main(void) { s.DeviceAddress = 1; s.NumRxDataBytes = 0x55; if (--s.NumRxDataBytes) { while(1); } } ///////////////////////////////////////////// Andy Leiper IET Ltd Quote Link to post Share on other sites
davidb 0 Posted February 1, 2011 Report Share Posted February 1, 2011 This problem also exists on V6.97 #include <system.h> typedef struct { unsigned char DeviceAddress; unsigned char NumRxDataBytes; } TTestStruct; TTestStruct s; void main(void) { s.DeviceAddress = 1; s.NumRxDataBytes = 0x55; if (--s.NumRxDataBytes) { while(1); } } As does this but with a different error: #include <system.h> unsigned char s[] = {1,0x55}; void main(void) { if (--s[1]) { while(1); } } However this works: #include <system.h> typedef struct { unsigned char DeviceAddress; unsigned char NumRxDataBytes; } TTestStruct; TTestStruct s; void main(void) { s.DeviceAddress = 1; s.NumRxDataBytes = 0x55; if (--s.NumRxDataBytes != 0) { while(1); } } As does this: #include <system.h> unsigned char s[] = {1,0x55}; void main(void) { if (--s[1] != 0) { while(1); } } Regards davidb Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.