comment style
Ron Irvine
ron at scocan.sco.COM
Wed Jan 9 03:40:14 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.
>
> Henry Spencer at U of Toronto Zoology
The four compilers: gcc 1.38 on a 386, SCO/Microsoft C 386, AT&T C 386,
and Turbo C++/C on DOS. Four very different compilers.
|-----------------
| ANSI C Section 3.1.9 Comments:
|
| Except within a character constant, a string literal, or a
| comment, the characters /* introduce a comment. The contents of
| a comment are examined only to identify multibyte characters
| and to find the characters */ that terminate it. 26
|
| 26. Thus, comments do not nest.
|----------------
Thus, a compiler that gives a warning of nested comments upon
finding the characters /* within a comment must have "examined"
the contents of the comment beyond that specified by the standard
and is in violation of the standard. So, the four compilers I used
were in fact processing the code correctly and were correct in not
producing a warning.
Ron Irvine, ron at sco.com
More information about the Comp.std.c
mailing list