Comments and pragma lines
Mark Hall
markhall at pyramid.pyramid.com
Thu Dec 1 03:58:44 AEST 1988
In article <9007 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <48957 at pyramid.pyramid.com> markhall at pyramid.UUCP ( me ? ) writes:
>-#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.
>
>How about explaining how you deduce that? I'm sure the comment was
>supposed to have been replaced by a space character before the #pragma
>line was ever (pre)processed.
Did *I* post that noise here? Dang. I meant to send it to
rec.humor.funny. Yes, of course, how stupid of me.
The rest of the question still may be of interest. I was working on
the `future' cpp and was wondering what I should do about gracefully
ignoring #pragma's that were not supported by our compiler. If the
following pragma were legal:
>-#pragma sunbakedchars ^%*#%/*!@
then how in the world would my cpp be able to tell, without knowing the
special semantics of `sunbakedchars', that the /* was not an open
comment? If my `cpp' grabbed it as an open comment, it could wreak havoc
on an otherwise legal program . . . .
The question I should have asked (wait, I did ask it!) was whether this
is legal. After having actually read the pertinent sections of XJ311
(no really, I read them this time), I see that /* can only occur as an
open comment or within a string/char literal. So if you see /* outside
of a " or ' string, you have yerself an open comment.
Hooray for the tokenization of preprocessor directives.
Sorry for the messing up the S/N ratio. It was getting good for a
while there.
-Mark Hall (smart mailer): markhall at pyramid.pyramid.com
(uucp paths): {amdahl|decwrl|sun|seismo|ames}!pyramid!markhall
More information about the Comp.std.c
mailing list