// and \ (was Re: Software maintenance)



On 9/21/2010 3:52 PM, Seebs wrote:
On 2010-09-21, Keith Thompson<kst-u@xxxxxxx> wrote:
Seebs<usenet-nospam@xxxxxxxxx> writes:
I have never seen \ at end of line used by anything but mechanical
code processors.

I think you're forgetting about multi-line macro definitions.

You're right, obviously I am.

And I've even seen comments used in them. Although I think always
/**/ comments.

I don't think I've ever used comments _within_ a multi-line macro definition.

But, my mind comes up with all sorts of weird "what if" questions when reading threads such as this, even though I would probably never use code like this...

What does the standard say of "\" at the end of a line with a "//" comment? My compiler gives a warning, but "continues" the comment onto the next line:

char *pt = "This is a line" // comment \
"(foo)" \
"(bar)"
"(baz)";

I get this warning twice:

single-line comment contains line-continuation character

and the string contains "This is a line(baz)".

Ditto for gcc (with "-Wall"), though the warning is worded

warning: multiline `//' comment

I know that compilers are allowed to give any "warnings" that they like (for example, "warning: 'int i;' is cliche" would be perfectly legal), but "inquiring minds want to know".

--
Kenneth Brody
.