Yet Another Argument for Nested Comments

Stephen Clamage steve at taumet.com
Wed Jan 30 03:20:59 AEST 1991


scl at unislc.uucp (Sean Landis) writes:

>I had a header file, hash.h, that looked like:

>#ifndef HASH_H
>#define HASH_H

>... The code ...

>#endif /* HASH_H

In this example, an ANSI-conforming compiler is obliged to report a
comment which is not terminated in the file in which it started.  A 
helpful compiler would indicate the line on which the comment began.
This would have shown you the error immediately upon the first compilation.

Even though standard C does not have nested comments, a compiler may warn
about something that looks like a nested comment.  (A compiler may warn
about anything at all, so long as it does not reject or misinterpret a
legal program.)
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list