Menu

#314 Highlight #if 0 ... #endif as a comment

open
nobody
None
5
2012-09-26
2004-10-06
Anonymous
No

Some programmers like to use #if 0 ... #endif to
comment things out, especially since it nests. I
propose that such #if blocks be highlighted as comments.

Specifically, suppose that all normal comments are
conceptually removed first (since preprocessor
directives can be commented out). Next, where #if 0 is
encountered, check for the corresponding #else and/or

endif. All the lines between them (except preprocessor

directives) would then be given the syntax highlighting
normally applied to comments. If there is an #else,
then normal syntax highlighting would occur between the

else and #endif, since that part is not commented.

Note that it is possible for whitespace to occur at the
beginning of the line before the #; as well as between
the # and the "if", or "else", or whatever.

I also suggest that an analogous rule be applied to the

else part of #if 1 ... #else ... #endif.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.