Comments and pragma lines

Brian Katzung katzung at laidbak.UUCP
Wed Nov 30 03:31:36 AEST 1988


In article <48957 at pyramid.pyramid.com> markhall at pyramid.UUCP (Mark Hall) writes:
>Consider the following source:
>
>#pragma rotate lid counterclockwise    /* store pointers in
>					* Best Foods 
>					* Mayonaise Jars.
>					*/
>
>Is it legal to start the comment on the pragma line?  From what I read*
>in the standard, it is illegal.  Fine.  For such cases, I'd like to see the 
>message:
>
>error: <file>.c: line 1, cannot open comment on #pragma line

Which part of the standard were you "reading"?

The comment should have been reduced to a single space by the time the
#pragma directive is interpreted.  At that time, you might get a com-
plaint about "extra tokens" or some other syntax error, but only if the
preprocessor doesn't like trailing white space.

>#pragma ascii sunbakedchar &^%$/*()!

If that is supposed to be a character list, the preprocessor/compiler
writer can probably make it a lot easier on herself by using a string
literal.

>then of course the compiler can't know in general that ``/*'' in the
>pragma line is the ``open comment'' token.  The consequence of this is

Comments (really white space) are no longer significant by the time the
compilation phase occurs--white space preprocessor tokens would normally
just be discarded when the compiler token stream is created.

 -- Brian Katzung  ...!{sun,spl1}!laidbak!katzung



More information about the Comp.std.c mailing list