Nested Comments in C -- A recent experience

Peter da Silva peter at ficc.uu.net
Sun Mar 11 23:11:43 AEST 1990


| Well, for once in a long while I've got a few cents to throw in.
| Just got done spending 3 hours looking for a "bug" which turned
| out not to be a "bug" at all; rather it went undetected as a
| programming error BECAUSE our C compiler doesn't handle nested
| comments (like most C compilers don't).

Alternatively, the problem was cause because the comment wasn't terminated
by the end of the line. I think a better fix than making comments nest would
be to add "// ... <eoln>" comments like C++ uses. Then in the next release
of the standard deprecate "/* ... */" comments.

This would also solve the old "a = *b/*c;" problem as well.

Nested comments are a fertile source of potential bugs. I'm not going to
rehash the old "comment seperator in string vs. commented-out code" argument.
Just sit down and think of the ramifications a little while...
-- 
 _--_|\  `-_-' Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
/      \  'U`
\_.--._/
      v



More information about the Comp.lang.c mailing list