ambiguous why?

Chris Torek chris at mimsy.UUCP
Tue Apr 5 23:50:25 AEST 1988


In article <1303 at PT.CS.CMU.EDU> edw at IUS1.CS.CMU.EDU (Eddie Wyatt) writes:
>... I got an error message that said something to the extent:
> 	warning ambiguous assigment: assignment op taken

C used to have =op operators; it now has op= operators.  In `old C'
one wrote, e.g.,

	i =- 1;

rather than

	i -= 1;

This meant that a statement such as

	i=-1;

was uncertain: did you mean decrement i by 1, or did you mean
assign -1 to i?  In `old C' the answer was to decrement i.

Some compilers (notably PCC) have accepted and warned about `old
fashioned' assignment operators for nearly 10 years.  The above
warning is given whenever the compiler sees `=-', to tell you
that it was not sure whether you meant `= -' or `-=', but that
it assumed the latter.  In particular, if you write

	int i=-1;

the compiler thinks you meant

	int i -= 1;

which is syntactically incorrect.

The easiest fix for this is to remove the `old C' compatibility
support.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list