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

compilre does not complain of "," instead of ";"

Hi I have the following code static bit cc_0 = 0;
...... if ((!CC_GDO_0 && cc_0) == 0) return 0;

cc_0 = 0, // here I have a , instead of ;

temp = SpiReadStatus(CCxxx0_MARCSTATE);
.....
I am surprise that the compiler does not generate or warn me of the comma error?

I have version 87.08 of C51.

Parents
  • I am surprise that the compiler does not generate or warn me of the comma error?

    The compiler is correct. A comma is a sequential evaluation operator in C, which allows putting several operations in places where only one would be allowed, for example

    for(i = 0, j = 0; i < 10; i++)
    

    It is also perfectly valid, though somewhat pointless, to use this operator in normal expressions.

Reply
  • I am surprise that the compiler does not generate or warn me of the comma error?

    The compiler is correct. A comma is a sequential evaluation operator in C, which allows putting several operations in places where only one would be allowed, for example

    for(i = 0, j = 0; i < 10; i++)
    

    It is also perfectly valid, though somewhat pointless, to use this operator in normal expressions.

Children