Re^4: Why nested comments not allowed?

Dan Barrett barrett at jhunix.HCF.JHU.EDU
Fri Feb 23 10:09:29 AEST 1990


In article <13771 at cbnewsc.ATT.COM> dalenber at cbnewsc.ATT.COM (Russel Dalenberg) writes:
>>>	printf("A comment is ended with */");
>
>I said: how do you handle the case where the above line of legal C is
>commented out.  If it's not commented out, there is no problem.
>
>The "usual" way to comment out such code would be:
>
>/*	printf("A comment is ended with */"); */
>
>Since quotes have *NO* significance within comments, the above comment
>ends with the first "*/" found; with *both* nested and non-nested comments!

	It seems there are 2 issues here.  The first is "How to parse?"
The second is "How to prevent us from tripping ourselves up?

	The statement:

	/*	printf("A comment is ended with */"); */

is easy to parse -- the comment truly closes at the */ in the string.
However, that */ is causing a problem probably unwanted by the programmer.

                                                        Dan

 //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
| Dan Barrett, Department of Computer Science      Johns Hopkins University |
| INTERNET:   barrett at cs.jhu.edu           |                                |
| COMPUSERVE: >internet:barrett at cs.jhu.edu | UUCP:   barrett at jhunix.UUCP    |
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////



More information about the Comp.lang.c mailing list