In article <ln************ @nuthaus.mib.or g>, Keith Thompson <ks***@mib.or g> writes:
Jason Curl <j_********@mot orola.com> writes:
Some compilers will see a nested comment and see that line 3 contains
the end of the comment, other compilers will see line 2 ending the
comment and fail compilation on line 3.
No, nested comments are not part of the standard. Since some code
actually depends on a "/*" within a comment being ignored, a compiler
that allowed nested comments (at least in its default mode) would
cause problems.
For example, I've worked with at least one programmer who liked to put
a comment at the end of nearly every line, and liked to comment out
code by inserting "/*" at the beginning of the line, thus:
foo(x); /* do something */
/* bar(x); /* do something else */
/* baz(x); /* and yet another thing */
return x;
A compiler that "allowed nested comments" (ie, failed to process
comments as mandated by the C language) would fail to compile this
correctly.
Now, this is a poor practice, for a number of reasons; for example,
if this programmer had put /* at the beginning of the final line
above, the comment would have extended until a */ was found further
down in the source file. It's much better to use #if / #endif to
suppress interpretation of a section of code. However, there is C
code which uses it, and so "supporting " nested comments would be a
Bad Thing.
--
Michael Wojcik
mi************@ microfocus.com
Then a good friend got very ill, and it made Pernsteiner realize that
"life is short. This was an opportunity to be silly."