Hi Friends, I'm Currently working on C51v6.02 developed by Keil, I'm facing a problem with the compiler when I compile a similar code like this
main() { char xdata *Data_Ptr = 0x0000; /* Pointer to the 0x000 location */ while(some loop) *Data_Ptr++; /* Points to the next data location on the RAM-- here 0x0001 */ }
.\FILENAME(LINENUMBER): warning C275: FILENAME: expression with possibly no effect
Proudly wasting time since 1981
Yaswanth, if you use:
main() { char xdata *Data_Ptr = 0x0000; /* Pointer to the 0x000 location */ while(some loop) Data_Ptr++; /* Points to the next data location on the RAM-- here 0x0001 */ }
char xdata *Data_Ptr = 0x0000;
char xdata *Data_Ptr; Data_Ptr = 0x0000;
Vaclav, I guess we need to do it this way.
char xdata *Data_Ptr; Data_Ptr = (char *) 0x0000; /* I guess this is the way it must be done */
/* If done this way */ Data_Ptr = 0x0000; /* you are not type casting it then in that case the compiler should/will give a warning -- Haven't tried it though. */
Data_Ptr++; /* Will point to the next location */ *Data_Ptr++; /* But surely this will point to the next location */
*Data_Ptr++;
Hmm... Not sure what "the correct way" means. But the rest of the world increments a pointer this way:
Data_Ptr++;
++Data_Ptr; or Data_Ptr += 1; or Data_Ptr = Data_Ptr + 1;
*Data_Ptr++; this expression is same as *(Data_Ptr++); or Data_Ptr += 1, *Data_Ptr;
Got you... Thanks Mike. -Yaswanth
View all questions in Keil forum