Comment Syntax

David Wald wald at theory.lcs.mit.edu
Wed Nov 14 05:18:56 AEST 1990


In article <48.UUL1.3#5077 at aussie.COM> rex at aussie.COM (Rex Jaeschke) writes:
>> In article <HAGERMAN.90Nov7193212 at rx7.ece.cmu.edu> hagerman at ece.cmu.edu (John Hagerman) writes:
>> >Why didn't // ... newline comments make it into ANSI C?
>> 
>
>Let me suggest that you CANNOT add // comments to an ANSI C compiler 
>WITHOUT some hacking. Consider the following example:
>
>int i;	// this comment ends in a backslash \
>int j;
>
>f()
>{
>	i = j;	/* error: j is not declared */
>} 
>
>ANSI's phases of translation require that backslash/new-lines be 
>processed BEFORE comments. In this case the 2 declaration lines would 
>become:
>
>int i;	// this comment ends in a backslash int j;

How much of a problem would this be?  It would mean that \\\n behaves
the same in comments as outside them, but that is already the case.
What do BCPL or C++ do with a comment like this?

-David
--
============================================================================
David Wald                                           wald at theory.lcs.mit.edu
============================================================================



More information about the Comp.std.c mailing list