#1211 C++ Comments and continuation characters..

Cosmetic
closed-invalid
Neil Hodgson
Scintilla (790)
3
2011-11-01
2011-08-17
Anonymous
No

I originally reported this on Notepad++ but was told that it needed to be reported on Scintilla. The problem is related to the handling of the continuation character when it is the last item of a C++ style comment line.

For example:
a=0;
// This is a comment that happens to have a continuation character at the end \
a=1;

The C/C++ compiler will treat the "a=1;" line as a continuation of the comment line. You will get a warning (thankfully) but Notepad++ doesn't recognize the continuation character as a continuation of the comment. With MS VS it will color code both the comment line and the "a=1;" line to give the programmer a visual of what is going on.

I ran into this because I had the following in my comment line:
// this is my comment from the directory /a/b/c/
if (a==1)
{ }

The compiler gave me a warning of a multiline comment but I didn't pay attention to it... it then commented out the if statement and allowed the code to fall into the block set off by the if.

It would be useful to have the parser recognize the continuation character at the end of the single line comment and have the next line color coded appropriately to give a visual to the developer that the next line is also considered a comment line.

Discussion

  • Neil Hodgson
    Neil Hodgson
    2011-08-17

    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 3
    • status: open --> open-invalid
     
  • Neil Hodgson
    Neil Hodgson
    2011-08-17

    The C++ lexer recognises a final '\' as a continuation. see this screenshot:
    http://scintilla.org/Continuation.png

    In the problematic sample, the comment line finishes with a '/' not a '\' and '/' is not a continuation character.

     

  • Anonymous
    2011-08-18

    Sorry, you are correct. The comment line has to end with '\'.

     
    Last edit: Anonymous 2013-10-20
  • Neil Hodgson
    Neil Hodgson
    2011-11-01

    • status: open-invalid --> closed-invalid