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

if condition

Hello,
I was compiling my firmware program written in
C using Keil microVision2 V2.4 compiler.
The target is c8051F120 microcontroller.

I noticed that the compiler accepted the following:
if (A == B, 1) {;}

Does anyone know why? I would think that a syntatically error is committed here.

Thanks in advance.

HL

Parents
  • "The comma operator, of course, has it's (sic) uses, but allowing it where "the result is discarded" is nothing but an obfusciation allowance."

    The whole point of the comma operator is precisely that it allows you to discard the result of the left-hand operand!

    The place where it can be useful is where the expression has side-effects...

    As neither expression in the example given has side effects, would some compilers give a "Code with no effect" warning here?

Reply
  • "The comma operator, of course, has it's (sic) uses, but allowing it where "the result is discarded" is nothing but an obfusciation allowance."

    The whole point of the comma operator is precisely that it allows you to discard the result of the left-hand operand!

    The place where it can be useful is where the expression has side-effects...

    As neither expression in the example given has side effects, would some compilers give a "Code with no effect" warning here?

Children