We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Could anyone enlighten me on pointer arithmetic please? Assigning a constant is fine, but a warning is generated when using a variable. (The code does do what I expect though.) The warning is : 'long' converted to 'xhuge' pointer
void Test() { long x; char xhuge *ptr; x=2; ptr = 0x80000 + 0x01; // no-warning ptr = 0x80000 + x; // warning generated x = 0x80000; ptr += x; // no-warning ptr = x; // warning generated }
Explicit cast to a pointer type will suppress the warning:
ptr = (char xhuge*)(0x80000 + x);
ptr += x;
Thanks! Andy