-
old style assignment
I was indenting some code with a program called indent. I accidently indented one of my own codes I wrote, but it gave me this warning.
Code:
indent: test.c:8: Warning:old style assignment ambiguity in "=-". Assuming "= -"
the code was What is ambiguous?
-
without seeing the actual code line it would be hard to see why. I would venture to guess it wants a space between = and - to avoide confusion between -=1 and =-1 (example).
-
that is what I though. I just thought that it wouldn't really be confused with -=.
-
well lint is pretty anal retentive :)
-
I think =- used to be the same as -=, so with under the old style
mov=-8; could mean either:
mov = -8;
Or:
mov = mov - 8;
-
>What is ambiguous?
Wow, that's an old warning. :) Back in the dark ages when the compound assignment operator was added to C, it began with the = and ended with the operation being performed, =- instead of -=, etc... But this caused plenty of confusion because many programmers feared spacing between operators and expected (for some odd reason) things such as v=*p; and x=-y to assign the value pointed to by p to the varible v and the negated value of y to be assigned to x, respectively. The former would try to multiply v by p and the latter would subtract y from x. In light of the surprises, the compound assignment operators were reversed to begin with the operation and end with the = so that these styles wouldn't break the meaning of the code.
But this was some time ago, and I don't know of any compiler today that could possibly parse move=-8 incorrectly.
-
It wasn't a compiler, it was a program that automatically indents:
http://www.gnu.org/software/indent/indent.html