[comp.lang.c] Comment removal

middleto@sdsu.UUCP (Tom Middleton) (02/06/89)

In article <> scm@datlog.co.uk ( Steve Mawer ) writes:
>If you've ever looked at the output from
>the C compiler's preprocessor (on every
>system *I've* seen, anyway) you'll find
>that all comment lines are replaced with
>blank lines.

i=1/* this is a comment */1 ;
j=1/* this is
a comment */1 ;

I tried the above on our SUN, our ELXSI and our CELERITY.  The results
were the same for all three.  The second line resulted in an error which
would indicate the comment was replaced by white space of some sort.
However, the first line worked just fine and the value of i when printed
was 11.  This would seem to indicate the comment was simply removed and
not replaced with whitespace (i=1 1; is an error).

Don't know if this is significant at all and I don't recommend comments
inside of constants but thought it was interesting enough to mention.
replaces it with nothing.

-- 
 G O    P A D R E S !		Thomas Earl Middleton
    1989			aka Happy Bare
 N L    C H A M P S !		UUCP  ...!ucsd!sdsu!middleto
 W S    C H A M P S !		ARPA  middleto%sdsu.uucp@ucsd.edu

bph@buengc.BU.EDU (Blair P. Houghton) (02/09/89)

In article <3466@sdsu.UUCP> middleto@sdsu.UCSD.EDU (Tom Middleton) writes:
>In article <> scm@datlog.co.uk ( Steve Mawer ) writes:
>
>i=1/* this is a comment */1 ;
>j=1/* this is
>a comment */1 ;
>
>I tried the above on our SUN, our ELXSI and our CELERITY.  The results
>were the same for all three.  The second line resulted in an error which
>would indicate the comment was replaced by white space of some sort.
>However, the first line worked just fine and the value of i when printed
>was 11.[...]

Bad compiler.  K&Red1 states (word-of-god-time, here... :-) on pg. 8,
"Any characters between /* and */ are ignored by the compiler;
they may be used freely [here's the emphasized part -ed.]
	ANYWHERE A BLANK OR NEWLINE CAN."

I.e., any compiler that thinks a comment is zero-length whitespace
is (umbrellas up, let's hear it, girls!) broke-broke-broke.

Okay, I'll get a grip.
The C Reference Manual appendix to K 'n' R pere only says that "comments
do not nest."
It's entirely likely that the guys with "Standard Conforming" tattooed
on a banner under a arrow-pierced heart on their ctrl-C'ing arm have
a much different idea of what sort of whitespace a comment should be
allowed to be.

>Don't know if this is significant at all and I don't recommend comments
>inside of constants but thought it was interesting enough to mention.

Mention it to the company that wrote the compiler.

Considering that there were _three_ compilers that busted, either someone
isn't paying attention or I'm using superseded info.  My obvious conceit
precludes my choosing the latter.

> G O    P A D R E S !

No comment.  ;->

				--Blair
				  "Except for all this Boggs bull,
				   I'm a Sox fan."