Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#529 Macro ending with backslash highlights non-macro line

Tony Reina
IDE (174)

When a macro ends the last line with a backslash the next line with text is also marked as macro, although there is an empty line in-between.

I attached a screenshot showing it.

My version is


  • Tony Reina
    Tony Reina


    There's a continuation backslash after the last line (while (0)). That's an unnecessary symbol in the code. I'm not sure how the syntax parser should correctly interpret it. Perhaps you can find some documentation to support a particular behavior.

    At present, I think it is thinking the next line is a continuation, but since the next line is blank, then it is skipping that line and going to the next,next line (as your screenshot shows).

    What happens when you get rid of that last continuation symbol? It disappears right? Also, if you add a blank line within your line continuation, then you'll see that it correctly inteprets things. (e.g. put a blank line after "(DEST) = SOURCE")

    I'm basically not convinced at this point that this is an error in the parser, but just a literal interpretation of things based on an "error" in the source code. The C++ preprocessor might be smart enough to correct for it, but the editor is picking out a possible bug.

    What do you think?

  • I doubt it being tolerance on side of the preprocessor. GCC has gotten stricter in recent years, so I assume this code is correct and the highlighting is at fault. Maybe compare it to an other editor with syntax highlighting. I only got VS2008 at my hand and it doesn't highlight the macros at all.

    I have no documentation to support this, but looking at this page


    you will find this sentence in the "Multiline macros" section:

    "Notice that you do not need a slash at the end of the last line! The slash tells the preprocessor that the macro continues to the next line, not that the line is a continuation from a previous line. "

    So the preprocessor will stop at the first line, that doesn't end with a backslash. That's way I figured the preproccesor works.

  • Tony Reina
    Tony Reina

    I tried it with VS2008 and the code folding seems to include the blank lines, but not the next line after that (i.e. it behaves as you'd expect even despite the \ on the last line). I suppose I'll look into "correcting" the behavior, but as the C++ preprocessor doc you linked said, it doesn't need that last slash (and seems counterintuitive to include it). So my point is that the way it is currently highlighted is not necessarily wrong, it just isn't exactly what one may expect.



Cancel   Add attachments