This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pointer Incrementing Warning

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 */
}

when I compile this it gives the following warning message,
 .\FILENAME(LINENUMBER): warning C275: FILENAME: expression with possibly no effect 

Is there any way to avoid this warning message?? Thank you,

With Regards,
Yaswanth

Proudly wasting time since 1981 

Parents
  • I don't think the warning message is about pointer incrementing, instead, it is telling you that you are not doing any assignment operations in that loop - "expression with possibly no effect ".

    That's exactly what it's telling you. Look folks, we need to learn ISO/ANSI C before we can start attacking the Keil compiler. If * didn't have precedence over ++ then how would the classic memcpy() example ever work? E.g.

    while (count--)
    {
        *pDest++ = *pSrc++;
    }
    Anyhow, now that we all understand some precedence let's look at what you do with your dereferenced value... nothing. It's no different that saying:
    int main(void)
    {
        int status;
        for (;;) status; /* legal but useless */
    
        return 0;
    }

Reply
  • I don't think the warning message is about pointer incrementing, instead, it is telling you that you are not doing any assignment operations in that loop - "expression with possibly no effect ".

    That's exactly what it's telling you. Look folks, we need to learn ISO/ANSI C before we can start attacking the Keil compiler. If * didn't have precedence over ++ then how would the classic memcpy() example ever work? E.g.

    while (count--)
    {
        *pDest++ = *pSrc++;
    }
    Anyhow, now that we all understand some precedence let's look at what you do with your dereferenced value... nothing. It's no different that saying:
    int main(void)
    {
        int status;
        for (;;) status; /* legal but useless */
    
        return 0;
    }

Children
No data