Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Comments format: comments extending over multi-line

Thread Tools

Comments format: comments extending over multi-line

Michael Wojcik
Posts: n/a

In article <(E-Mail Removed)>, Keith Thompson <(E-Mail Removed)> writes:
> Jason Curl <(E-Mail Removed)> 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

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 Removed)

Then a good friend got very ill, and it made Pernsteiner realize that
"life is short. This was an opportunity to be silly."
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
Extending screen over 2 monitors NOTTNICK Computer Support 1 11-11-2007 09:42 PM
A program to replace all JS comments with JSP comments in jsp files Javascript 4 06-03-2006 02:00 PM
A program to replace all JS comments with JSP comments in jsp files Java 0 06-02-2006 06:35 AM
Extending a T1 over Ethernet / Fiber link Rick G Cisco 2 07-11-2003 09:22 PM