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
  • OPINION!!, nothing else. [inserted for the benefit of those who are more interested in my language that facts]

    No errors. It's perfectly valid syntax.

    Another example of the obscure "syntactical allowances" built into C to guarantee that, if you so decide, you can write C than 'nobody' can understand.

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

    Erik

Reply
  • OPINION!!, nothing else. [inserted for the benefit of those who are more interested in my language that facts]

    No errors. It's perfectly valid syntax.

    Another example of the obscure "syntactical allowances" built into C to guarantee that, if you so decide, you can write C than 'nobody' can understand.

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

    Erik

Children