>
>
> LCLint 2.2a --- 04 Sep 96
>
> xxx.c: (in function main)
> xxx.c:13,5: Test expression for if is assignment expression: i = foo()
> The condition test is an assignment expression. Probably, you mean to use ==
> instead of =. If an assignment is intended, add an extra parentheses nesting
> (e.g., if ((a = b)) ...) to suppress this message. (-predassign will suppress
> message)
> xxx.c:13,5: Test expression for if not bool, type int: i = foo()
> Test expression type is not boolean or int. (-predboolint will suppress
> message)
>
> Finished LCLint checking --- 2 code errors found
>
>
> gcc 'fixes' obvious coding errors like this. If a compiler fixes
> these errors, it should fix the source while it's at it so I don't
> have to see them again.
No, gcc doesn't "fix" anything. You get a warning because writing "="
in a if-test is a common typo among C beginners and people who
program other languages such as pascal. (Pascal use "=" for comparison)
It is just a warning that something might be wrong. I always turn it
off as it annoys me. A good C programmer shouldn't have trouble
with it and it is perfectly readable for those fluent in C.
Some people thinks if (a=b) is bad practice, some like it. It
is definitely not a compiler bug though.
Helge Hafting
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/