comment style

Norman Diamond diamond at jit345.swstokyo.dec.com
Tue Jan 8 12:32:13 AEST 1991


In article <1050:Jan701:40:4791 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:

>4. It is always obvious, to both human eye and mechanical parser, where
>a // comment ends (viz., the end of the line). It is not so trivial to
>locate the next */.

If it's so obvious, then why was there so much confusion for a while, over
in the C++ newsgroups?  It seems to have been resolved, that if a comment
constains a backslash followed by a newline, the backslash and newline get
eaten early the way ANSI C says, and extend the comment.  But for a while,
they didn't find it so obvious.

In article <1991Jan05.194321.12428 at kithrup.COM> sef at kithrup.COM (Sean Eric Fagan) writes:

>Is the if statement part of the comment, or not?  In C comments, no
>characters are special.

Well, after the trigraphs have been kluged, backslash-newlines eaten, and
terminating asterisk-slashes honored, there are no special characters
remaining in the comments.

>/lib/cpp says that
>	/*
>	This is a comment?
>	/\
>	*
>results in an unterminated comment, while msc and gcc both accept it.

I'd agree that
  /* This is a comment? /*
results in an unterminated comment.  What does /lib/cpp say when you
terminate the comment?  How old a /lib/cpp are you using?
--
Norman Diamond       diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.



More information about the Comp.std.c mailing list