comment style
Ron Irvine
ron at scocan.sco.COM
Sat Jan 5 03:43:55 AEST 1991
A need for // (real) comments:
#include <stdio.h>
void main() {
int *p;
int a;
int f = 10;
int n = 5;
p = &f;
a = 100/*p /* calculate first factor */
+ 25/n; /* and second factor */
printf("The answer is %d, %s\n", a, (a==15)?"OK":"BAD");
}
The actual program that contained this problem was very complex.
It took two of us a day to figure out what had happened.
Flame On:
It is incredibly STUPID to have the start of comment token the same
as a LEGAL combination of other language tokens.
I have run this program on 4 different C compilers and none of them
even warned of a potential problem (nested comments).
Comments are part of the syntax of the language and should never
have been left to the EVIL pre-processor to "handle".
Flame Off:
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. If // style comments had been
used in the above program the compile would have failed.
Ron Irvine, ron at sco.com
More information about the Comp.std.c
mailing list