comment style

Stephen Clamage steve at taumet.com
Sun Jan 13 05:05:57 AEST 1991


andrew at resam.dk (Leif Andrew Rump) writes:

>Just a single question: Does TC warn you about comment (/*) inside
>a comment (//)? If not then _I_ will never mix // and /**/ and maybe
>even abandon // completely!!!

Comments do not nest.  A // introduces a comment which extends *to*
(not through) the end of the line.  There is no problem in mixing the
two styles.  For example:

//	foo(bar);	/* I'm not sure if I want this call */

The entire line can be commented out by placing the // at the start, and
has no effect on any other code in the program.  Similarly:
/*
	foo(bar);	// for foo-ish systems
	fee(fie);	// for foo-ish or fee-sh systems
*/
The two line can be commented out with the /* */ even though they contain
//-style comments.

A consistent commenting style is helpful.  I use // for trailing inline
comments, and /* */ for block comments.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.std.c mailing list