Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!uakari.primate.wisc.edu!unmvax!pprg.unm.edu!topgun!mustang!nntp-server.caltech.edu!tybalt.caltech.edu!woody From: woody@tybalt.caltech.edu (William Edward Woody) Newsgroups: comp.std.c++ Subject: Re: backslash-newline inside C++ comments? Message-ID: <1990Oct19.165355.28351@nntp-server.caltech.edu> Date: 19 Oct 90 16:53:55 GMT References: <1990Oct18.230000.14131@twinsun.com> Sender: news@nntp-server.caltech.edu Organization: JPL Computer Graphics Laboratory, Pasadena. Lines: 47 Nntp-Posting-Host: tybalt.caltech.edu In article <1990Oct18.230000.14131@twinsun.com> eggert@ata.twinsun.com (Paul Eggert) writes: >Is the sequence > > // a co\ > mment > >a legal comment in ANSI C++? ANSI C's translation phases are as follows: > > 1. Trigraphs are replaced by non-trigraph equivalents. > 2. backslash-newline pairs are removed > 3. The file is decomposed into preprocessing tokens and white space > (including comments). > ... > >If C++ is like ANSI C here, then it seems that the above sequence must be a >legal C++ comment. According to ELLIS, Margaret A., STROUSTRUP, Bjarne, "The Annotated C++ Reference Manual", pp 370ff, [Chapter 16, section 1]: 1. If needed, new-line characters are introduced to replace system-dependent end-of-line indicators and any other necessary system-dependent character set translations are done. Trigraph sequences are replaced by their single character equivalents. 2. Each pair of backshash character \ immediately followed by a new-line is deleted, with the effect that the next source line is appended to the line that contained the sequence. 3. The source text is decomposed into preprocessing tokens and sequences of white space. A single white space replaces each comment. A source file may not end with a partial token or comment. ... So, yeah, // This is a comment \ though a rather useless one. is a legal comment. God help me if I know why you'd ever want to *use* such a construction... -- William Edward Woody | Disclamer: USNAIL P.O.Box 50986; Pasadena, CA 91115 | EMAIL woody@tybalt.caltech.edu | The useful stuff in this message ICBM 34 08' 44''N x 118 08' 41''W | was only line noise.