Author Topic: Grey-out preprocessor block if not defined C\C++, v2011  (Read 2411 times)

JimmieC

  • Senior Community Member
  • Posts: 424
  • Hero Points: 16
Grey-out preprocessor block if not defined C\C++, v2011
« on: May 26, 2015, 03:26:41 pm »
Can SE grey-out a block of conditionally compiled code if the condition is not defined?
For example:


In header file:
#define ALARM_DBG 0

In .c\.cpp file:
#if ALARM_DBG == 1
         if(LampAlarm.I != 5 || AudioAlarm.I != 5)
         {
            asm( " NOP "); // breakpoint
         }
#endif


Code Composer 5.5 (Eclipse-based) will color the whole block if it is not-active code. Can SE do that as well?

Jim

JimmieC

  • Senior Community Member
  • Posts: 424
  • Hero Points: 16
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #1 on: May 26, 2015, 07:07:09 pm »
Here is a screen shot from CCS 5.5.

Maybe a feature that can be added to SE if it does not already support it. I am at v2011 so I have an older version.


rajkej

  • Senior Community Member
  • Posts: 285
  • Hero Points: 12
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #2 on: May 26, 2015, 08:48:27 pm »
SE does color code the blocks as in the attached example. If you are using some macros that SE doesn't have defined then you might want to go define them in tools->options->Languages->Application Langugages->C/C++->C/C++ Preprocessing.

JimmieC

  • Senior Community Member
  • Posts: 424
  • Hero Points: 16
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #3 on: May 26, 2015, 09:25:28 pm »
Adding the defines is an extra step but it is a work-around.

CCS 5.5 just figures it out from the source files. Maybe SE will implement this in a future release.

I will give your suggestion a try.


Thanks,
Jim

hs2

  • Senior Community Member
  • Posts: 2738
  • Hero Points: 288
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #4 on: May 27, 2015, 05:14:44 am »
This won't change at least in the foreseeable future because:
  • SE does not a full C/C++ build of all sources to retrieve the symbol information.
    Instead they have their own sophisticated, fast parsers (there is not only C/C++) for much better user experience.
    You know, a full rebuild on every source change might be expensive.
  • Every compiler comes with a bunch of built-in preprocessor flags changing with each compiler version.
    I guess there are zilliions of '#if _MSC_VER ...' or '#if __GNUC__ ...' out there ;)
  • Even when using compiler technology one might specify compile flags within a custom build system which can't be parsed by any generic tool.
    These must be hinted to the parser/compiler anyway.

CCS might do a more or less good job because it handles just it's very own CCS C/C++ projects.
Although I have my doubts that it's (still) 'fast and fluid' with larger projects b/c it's Eclipse based., But I'm biased ;)
Luckily there is an alternative :)

HS2
« Last Edit: May 27, 2015, 05:32:33 am by hs2 »

JimmieC

  • Senior Community Member
  • Posts: 424
  • Hero Points: 16
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #5 on: May 27, 2015, 01:25:25 pm »
Quote
>> b/c it's Eclipse based

Eclipse = sluggish.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4938
  • Hero Points: 404
Re: Grey-out preprocessor block if not defined C\C++, v2011
« Reply #6 on: May 27, 2015, 01:49:19 pm »
In addition to the problems mentioned above, SlickEdit would need precise include file information which users really don't want to take the time to set up. As already mentioned, a full parse with includes would drastically slow down tagging (a very bad thing).

At the moment, it makes more sense to make it easier for users to set their defines. There is still more we could do here. I thought we had a "Scan for defines" feature which allows you to pull out referenced defines out of a source file (like the current source file) and set them but it only seems to be available on the Selective Display dialog. There is an "Import..." button which can help but if you have tons of header files this isn't as helpful for quickly setting up defines so you can better view the current source file.