comment style

Henry Spencer henry at zoo.toronto.edu
Sun Jan 6 11:06:48 AEST 1991


In article <1991Jan04.164355.15674 at sco.COM> ron at scocan.sco.COM (Ron Irvine) writes:
>	a = 100/*p	/* calculate first factor */
>I have run this program on 4 different C compilers and none of them
>even warned of a potential problem (nested comments).

Four different compilers, or four different ports of the same compiler?
(Many Unix C compilers are really the same one, good [?] old PCC.)  An
alert compiler *will* warn about this.

>Comments are part of the syntax of the language and should never
>have been left to the EVIL pre-processor to "handle".

They aren't, and weren't.  What makes you think the preprocessor is involved?
In old compilers, typically *both* the preprocessor and the compiler do
comment elimination.  C's comment style was fixed before the preprocessor
even existed.

>The // comment style should have been adopted by the ANSI committee
>if for no other reason that to reduce the likelihood of a programmer
>falling into this horrendous trap...

Careless programmers would still fall into it, because vast numbers of
old compilers are still in the field, and code intended to be portable
must be acceptable to them.
-- 
"The average pointer, statistically,    |Henry Spencer at U of Toronto Zoology
points somewhere in X." -Hugh Redelmeier| henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.std.c mailing list