C needs reliable comments
Karl Heuer
karl at ima.isc.com
Sat Jan 19 03:12:56 AEST 1991
In article <2893 at cirrusl.UUCP> dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
>Did you realize that C is one of the few programming languages, perhaps the
>only one, in which you can never be sure of correctly commenting stuff out?
Nonsense. It seems to me that any language with delimited-pair comments has
the same property.
>(b) You can use #if 0 and #endif to comment out a block of code. Then
>[it breaks] if you have an invalid token or unbalanced quotes between these
I agree with Doug that this is a silly objection. But if we accept it...
>[proposal for a #comment...#endc block that is basically #if 0...#endif]
Objection (b) still applies. The following two lines
char *s = "continued\
#endc /*"; /* the string ends with a slash-star */
are a valid C fragment, but if you comment them out, you get something which
is indistinguishable from an attempt to comment out the incomplete fragment
consisting only of the first line.
Karl W. Z. Heuer (karl at ima.isc.com or uunet!ima!karl), The Walking Lint
More information about the Comp.std.c
mailing list