Is this correct a=/* comment */b;

Stephen Clamage steve at taumet.com
Wed Feb 6 03:56:39 AEST 1991


pat at ctycal.UUCP (Patrick Woo) writes:

>a=/* This is a comment */b;
>Just wondering whether the compiler should read the line as

>a = /*comment*/ b;
>or
>a =/ *comment ...;

Under Standard (ANSI/ISO) C, =/ is not a token, so the only valid reading is
	a = /*comment*/ b;

In K&R1 (1978), =/ and friends are listed as already obsolete -- 13 years
ago!  Some compilers continued to accept =/ as a token, but marked them
with a warning.

If a compiler (in violation of the Standard) now chooses to accept =/ as a
valid token, then the rule about "longest string which could be a token"
applies, and the compiler must interpret the example as
	a =/ *comment */ b;
which contains at least a syntax error.  I don't see why any compiler
should accept =/ and friends any more.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list