warning: '/*' within comment

diamond@tkovoa diamond at tkou02.enet.dec.com
Wed Jun 13 12:15:35 AEST 1990


In article <1990Jun12.222745.3015 at diku.dk> thorinn at skinfaxe.diku.dk (Lars Henrik Mathiesen) writes:

>If you know of an ANSI C compiler (I don't think it's ``perfectly
>valid'' otherwise) which does not lex #if'fed-out blocks into
>pptokens, please explain how it handles this conformant (I think)
>program:
>#include <stdio.h>
>#if 0
>I'll put a /* inside 's
>#endif
>#if 1
>Now it's a */. This program doesn't use comments.
>#else
>int main(int c, char *v[]) { printf("Hello, world!\n"); return 0; }
>#endif

This is not a conformant program.  If processed by an ANSI C compiler,
here is the result of preprocessing:
 [contents of <stdio.h>]
 Now it [character constant] t use comments.
There isn't necessarily whitespace next to the character constant, and
we don't know if brute-force tokenization actually occurs.
We still don't know if the preprocessor really tokenizes the if'ed-out
lines, aside from recognizing characters, strings, and comments:
 I [character constant] s
 int main(int c, char *v[]) { printf( [string constant] ); return 0; }

-- 
Norman Diamond, Nihon DEC     diamond at tkou02.enet.dec.com
Proposed group comp.networks.load-reduction:  send your "yes" vote to /dev/null.



More information about the Comp.std.c mailing list