🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2285

Re: comment style

#2285
From: Stephen Clamage
Date: Sat, 12 Jan 1991 18:19
43 lines
2005 bytes
thorinn@diku.dk (Lars Henrik Mathiesen) writes:

>brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
><Then you have a push-pull in the preprocessor between the #define, which
><takes everything up to the next newline, and the //, which takes
><everything up through the next newline. I'd say the #define should win...

>If the #define wins, // comments cannot be used as line continuations
>in macros. Pity, because I liked your idea of merging the comment and
>continuation mechanisms.

// comments extend *to* the end of the line, not through it.  They cannot
be used as line continuations.  So

	#define foo bar		// use bar instead of foo
	blah blah

is equivalent to

	#define foo bar
	blah blah

You also cannot use line continuation in the presence of // comments, because
the ANSI "phases of translation" apply.  The line continuation is applied
before comments are recognized, and everything past the // is lost.

	#define foo	// comment here	\ 
		bar

first becomes
	#define foo	// comment here bar
and then becomes
	#define foo
which presumably is not what was intended.

NOTE:  Not all existing preprocessors treat // comments the same way.
What I have stated above is as specified in the latest documentation
for C++.  Some existing (older) C++ compilers behave differently.
For C, // comments are an extension, not part of any standard, so who
knows what different compilers will do?
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Technical Details
Message-ID: <551@taumet.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!taumet!steve
References: <616@caslon.cs.arizona.edu> <17968:Jan804:38:1591@kramden.acf.nyu.edu> <1991Jan9.003543.3087@watmath.waterloo.edu> <29161:Jan903:10:3391@kramden.acf.nyu.edu> <thorinn.663630754@ragnarok.diku.dk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!taumet!steve
From: steve@taumet.com (Stephen Clamage)
Newsgroups: comp.std.c
Subject: Re: comment style
Message-ID: <551@taumet.com>
Date: 12 Jan 91 18:19:36 GMT
References: <616@caslon.cs.arizona.edu> <17968:Jan804:38:1591@kramden.acf.nyu.edu> <1991Jan9.003543.3087@watmath.waterloo.edu> <29161:Jan903:10:3391@kramden.acf.nyu.edu> <thorinn.663630754@ragnarok.diku.dk>
Organization: Taumetric Corporation, San Diego
Lines: 43