Article View: comp.std.c
Article #2226Re: comment style
From: Tim McDaniel
Date: Fri, 28 Dec 1990 16:09
Date: Fri, 28 Dec 1990 16:09
34 lines
2134 bytes
2134 bytes
iverson@ivy.uucp (Tim Iverson) screwed up, I'm afraid.
#include <stdio.h>
/* e.g. these lines are commented out /* even if they have comments */
/* You can also grep for "^/**/" to find where they all are.
/**/
main() { printf("Hello world\n"); exit(0); }
gcc -Wall -ansi -pedantic 72.c
72.c:2: warning: `/*' within comment
72.c:3: warning: `/*' within comment
72.c:3: unterminated string or character constant
The `*/' on line 3 ends the comment block. Iverson's scheme works
only if all existing comments fall at the end of the line.
In any event, the comment is wrong. `*' is a metacharacter for the
grep program, so the pattern matches lines starting with one or more
`/'s. "^/\*\*/" is more correct, when such comments are not indented.
(To forestall a misunderstanding: a C comment cannot be nested within
another comment, as in
/* comment comment /* nested comment */ more comment */
Never. If your compiler allows it, it is not compiling C at that
time. It is compiling a language that misleadingly resembles C. It
will fail to compile the following program, which has been legal C
since Cambrian times.
#include <stdio.h>
main() {/* int x; /* a count */ printf("Hello world!\n"); exit(0);}
)
--
Tim McDaniel Applied Dynamics Int'l.; Ann Arbor, Michigan, USA
Work phone: +1 313 973 1300 Home phone: +1 313 677 4386
Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel
Technical Details
Message-ID:
<MCDANIEL.90Dec28110944@dolphin.adi.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!umich!sharkey!amara!mcdanielReferences:
<276814F4.141@maccs.dcss.mcmaster.ca> <1990Dec21.014321.5000@kithrup.COM> <26036@uflorida.cis.ufl.EDU> <1990Dec27.215842.23685@ivy.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!umich!sharkey!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.std.c Subject: Re: comment style Message-ID: <MCDANIEL.90Dec28110944@dolphin.adi.com> Date: 28 Dec 90 16:09:44 GMT References: <276814F4.141@maccs.dcss.mcmaster.ca> <1990Dec21.014321.5000@kithrup.COM> <26036@uflorida.cis.ufl.EDU> <1990Dec27.215842.23685@ivy.uucp> Sender: news@adi.COM Organization: Applied Dynamics International, Inc.; Ann Arbor, Michigan, USA Lines: 34 In-reply-to: iverson@ivy.uucp's message of 27 Dec 90 21:58:42 GMT