comment style
Tim McDaniel
mcdaniel at adi.com
Sat Dec 29 03:09:44 AEST 1990
iverson at ivy.uucp (Tim Iverson) screwed up, I'm afraid.
#include <stdio.h>
/* e.g. these lines are commented out /* even if they have comments */
/* You can also grep for "^/**/" to find where they all are.
/**/
main() { printf("Hello world\n"); exit(0); }
gcc -Wall -ansi -pedantic 72.c
72.c:2: warning: `/*' within comment
72.c:3: warning: `/*' within comment
72.c:3: unterminated string or character constant
The `*/' on line 3 ends the comment block. Iverson's scheme works
only if all existing comments fall at the end of the line.
In any event, the comment is wrong. `*' is a metacharacter for the
grep program, so the pattern matches lines starting with one or more
`/'s. "^/\*\*/" is more correct, when such comments are not indented.
(To forestall a misunderstanding: a C comment cannot be nested within
another comment, as in
/* comment comment /* nested comment */ more comment */
Never. If your compiler allows it, it is not compiling C at that
time. It is compiling a language that misleadingly resembles C. It
will fail to compile the following program, which has been legal C
since Cambrian times.
#include <stdio.h>
main() {/* int x; /* a count */ printf("Hello world!\n"); exit(0);}
)
--
Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300 Home phone: +1 313 677 4386
Internet: mcdaniel at adi.com UUCP: {uunet,sharkey}!amara!mcdaniel
More information about the Comp.std.c
mailing list