Topic: //' comments with a trailing '\'.


Author: jleffler@earthlink.net (Jonathan Leffler)
Date: Fri, 17 Jan 2003 07:00:37 +0000 (UTC)
Raw View
apm wrote:
> I have a question about what the standard says about the C++
> comment convention '//'.  I have noticed that one compiler I use
> issues a warning when it finds a line beginning with '//' that
> ends with '\'. It says that it has found a multiline comment.
> It would seem that it joins lines that end in '\' before it deals
> with '//' comments. Is this right?

Yup.

> Section 2.7 of the standard does not seem to cover this case AFAICS
> but I note from section 2.1, clauses 2 and 3 that the processing
> of trailing backslashes is to be handled before preprocessor
> and comment directives. This suggests (to me) that the compiler
> is correct when it considers that the code has multiline comments.

The compiler is correct.  It also means that this is a single C++ comment:

/\
\
/ ...\
\ ....

The same should apply in C99 too, FWIW.


>



--
Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix 1.04.PC1 -- http://dbi.perl.org/

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: apm35@student.open.ac.uk (apm)
Date: Fri, 17 Jan 2003 00:23:39 +0000 (UTC)
Raw View
I have a question about what the standard says about the C++
comment convention '//'.  I have noticed that one compiler I use
issues a warning when it finds a line beginning with '//' that
ends with '\'. It says that it has found a multiline comment.
It would seem that it joins lines that end in '\' before it deals
with '//' comments. Is this right?

Section 2.7 of the standard does not seem to cover this case AFAICS
but I note from section 2.1, clauses 2 and 3 that the processing
of trailing backslashes is to be handled before preprocessor
and comment directives. This suggests (to me) that the compiler
is correct when it considers that the code has multiline comments.

I would appreciate any feedback on this, particularly from
people that are involved with the standards committee.

Regards,

Andrew Marlow.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]