MrZebra 0 Posted November 17, 2007 Report Share Posted November 17, 2007 Pointer addition only seems to work for inbuilt data types, not for structures. I've made a minimal test case to reproduce this, below. I guess I could get around it by casting to a char* and adding on sizeof(s), then casting back... but that's kind of annoying! The fact that "s++" works but "s+=1" doesn't definately looks like a bug! #include <system.h> struct ST { unsigned char x; }; void main(void) { struct ST *s; // Pointer to structure unsigned char *c; // Pointer to character c++; // OK s++; // OK c += 1; // OK s += 1; // error: illegal operation for operands 'unsigned char' and 'struct ST*' } Gives the result Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" usb.c -O1 -W1 -t 18F2450 BoostC Optimizing C Compiler Version 6.81 (for PIC18 architecture) (snip) C:\MrZebra\RaveRaffe\PIC\USBRaffe\usb.c(29): error: illegal operation for operands 'unsigned char' and 'struct ST*' C:\MrZebra\RaveRaffe\PIC\USBRaffe\usb.c(29:4): error: failed to generate expression Quote Link to post Share on other sites
Dave 0 Posted December 20, 2007 Report Share Posted December 20, 2007 Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" usb.c -O1 -W1 -t 18F2450BoostC Optimizing C Compiler Version 6.81 (for PIC18 architecture) (snip) C:\MrZebra\RaveRaffe\PIC\USBRaffe\usb.c(29): error: illegal operation for operands 'unsigned char' and 'struct ST*' C:\MrZebra\RaveRaffe\PIC\USBRaffe\usb.c(29:4): error: failed to generate expression Fixed in V6.82. Regards Dave 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.