Author Topic: C/C++ Color Coding - support #ifdef condition for "Color inactive code regions"  (Read 2999 times)

gfinlay

  • Community Member
  • Posts: 12
  • Hero Points: 1
I'm currently using SE 22.0.2.1.

I can get the C/C++ Color Coding feature for "Color inactive code regions" to work properly with the preprocessor directive, but only with constant values such as 0 or 1.  "#if 0".  The Inactive code will properly show as greyed out. 

However, I would like to see support for coloring inactive code for the #if <condition>, #ifdef <condition> and #ifndef <condition>  directives as well. For this to work, the coloring feature needs to evaluate preprocessor conditions or #defined switch values even if defined in header files.

For instance, I would expect to see the following code greyed out (after the #if directive)
#define USE_HUB_CLASS         (0)
.
.
#if USE_HUB_CLASS
      <code which should be greyed out here>
#endif

Likewise, I expect the inactive code colorization to work with #ifdef and #ifndef:
#undef ENABLE_FEATURE1
.
.
#ifdef ENABLE_FEATURE1
     <this code should be greyed out since switch is not defined>
#endif



Dennis

  • Senior Community Member
  • Posts: 3955
  • Hero Points: 515
For performance, our C/C++ tagging does not do full preprocessing (that is, it does not recursively read header files).  To get the color coding as you want, you'll need to tell SlickEdit that you have these symbols defined.

You can do that on a per-workspace basis:  Project > Workspace Properties > C/C++ Preprocessing...

or on a global bases:  Document > C/C++ Options > C/C++ Preprocessing...

gfinlay

  • Community Member
  • Posts: 12
  • Hero Points: 1
Hi Dennis,

Good answer.  I agree that a recursive search for #defines could adversely affect performance. With the "Workspace properties/ C/C++ Preprocessor options..."  I was able to import my defines and get the inactive regions to show properly based on whether I #define or #undef my symbols.

I suggest that the help screen for Language-Specific Color Coding Options help page (see qthelp://com.slickedit.texteditor/doc/ch12s11.htm#sect_options_menuanddialogs_14207_28494) could be improved a bit.
It should add a cross-reference link to C/C++ Preprocessor options help under the "Color inactive code regions" checkbox description to give a hint to the user to learn how to access and/or override  #define/#undef symbols in their workspace or globally. Perhaps something like

  • Color inactive code regions (C/C++ Preprocessing, eg. #if 0) - When checked, uses a single color for inactive code regions, instead of applying normal color coding.  For more information, see C/C++ Preprocessing.

where the C/C++ Preprocessing link points to the appropriate page:
         qthelp://com.slickedit.texteditor/doc/ch09s04.htm#sect_candcpp_11652_43883

Regards,
Gord