Author Topic: Color coding for #ifdef and #ifndef  (Read 590 times)

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Color coding for #ifdef and #ifndef
« on: October 03, 2021, 10:09:48 am »
SlickEdit Pro 2021 (v26.0.0.4 64-bit Qt5)

I observed the following:

#ifndef XXX
if symbol XXX is not defined, the enclosed text is colored as inactive code.

#ifdef XXX
if symbol XXX is not defined, the enclosed text is colored as normal code (i.e. not inactive code).

My $0.02: to be useful, those ^ colorings should be reversed.

When I do GoTo Definition of XXX, it says "No symbols found matching 'XXX'"


Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 3860
  • Hero Points: 509
Re: Color coding for #ifdef and #ifndef
« Reply #1 on: October 05, 2021, 12:08:10 pm »
With respect to the inactive code coloring, "defined" is defined as whether it the symbol is in the C/C++ Preprocessing Configuration either for the workspace (Project > Workspace Properties... > C/C++ Preprocessing) or at the language level (Document > C/C++ Options... > C/C++ Preprocessing).

Similarly, "not defined" is defined as something that is configured as a #undef in those same configuration options.

A symbol that is neither "defined" nor "not defined" can go either way, so if you have:
Code: [Select]
#ifdef MYSTERY_MEAT
   // active
#else
   // also active
#endif

The color coding uses the C/C++ preprocessing configuration rather than tagging simply for performance, it would be prohibitively slow (and potentially not completely accurate) for color coding to depend on what symbols are defined in tag files.

joecar

  • Senior Community Member
  • Posts: 385
  • Hero Points: 9
  • engineer/gearhead
Re: Color coding for #ifdef and #ifndef
« Reply #2 on: October 05, 2021, 10:28:47 pm »
Ok, thanks for the explanation.