Author Topic: #if 0 commenting  (Read 41126 times)

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: #if 0 commenting
« Reply #15 on: February 02, 2010, 02:06:39 AM »
This is a snippet of simple code showing #if 0 coloring not working.  I have Symbol Coloring enabled with the Undefined only scheme.  I've attached screen shots of the Colors and Symbol Coloring options pages and how the code looks in SlickEdit.

Code: [Select]
/* NOTE: g_iSystemState SET TO FLIGHT_INIT SINCE NO TEST MODE FOR NOW */
#if 0
           g_iSystemState = TEST_INIT;
#else
           g_iSystemState = FLIGHT_INIT;
#endif

I tried switching to some of the other predefined symbol coloring schemes and saw no rules listed for Inactive Code.  Nor did I see Inactive Code listed in the Symbol Types or Symbol Attributes options to allow me to define a new rule for it.

Ding Zhaojie

  • Senior Community Member
  • Posts: 194
  • Hero Points: 37
Re: #if 0 commenting
« Reply #16 on: February 03, 2010, 07:01:05 AM »
check this, good luck.

LBCEi

  • Senior Community Member
  • Posts: 261
  • Hero Points: 21
Re: #if 0 commenting
« Reply #17 on: February 03, 2010, 11:47:18 PM »
Thanks

That did the trick  ;D

Les

jerry_harling

  • New Community Member
  • Posts: 1
  • Hero Points: 0
Re: #if 0 commenting
« Reply #18 on: October 08, 2010, 07:36:05 AM »
Hi,

I am using SlickEdit Version 14.0.0.7.  I was wondering if I had a .h files containing all the #define MPC_feature 1, #define PTC_Advance_Power 0... and Slickedit are able to process all these define values in that single .h file and turn off portion of the code that is #define as "0" and retain those that is "1" base on the .h files.  The .h files is residing at some directory.

#if PTC_Advance_Power
   True  <-- this is set to gray color
#else
   False  <-- this will be active color in this case as PTC_Advance_Power is "0"
#endif

I do not want the code to disappear as I need to understand and might need to do debug.  Hope anyone can provide some help in this areas.  Perhaps a screen shot on how to configure that to make it work will be helpful.  Thanks!

Micha_1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: #if 0 commenting
« Reply #19 on: June 28, 2017, 02:54:48 PM »
Is there a way to show code as active/inactive based on the defines (automatically) generated in the selective display dialog?
I am testing SlickEdit Pro 2016 (v21.0.3.0 32-bit) and this does not seem to work - I have to manually add the defines in the C/C++ preprocessing dialog.
Why are these defines not synchronized?

Micha_1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: #if 0 commenting
« Reply #20 on: June 30, 2017, 07:16:12 AM »
@slickedit staff: Any plans to change/enhance this?

mjdl

  • Senior Community Member
  • Posts: 151
  • Hero Points: 18
  • SE Pro 2023 v28.0.2.0 64-bit Qt5 Win 11 23H2
Re: #if 0 commenting
« Reply #21 on: July 04, 2017, 05:19:40 PM »
I'm insufficiently expert to really answer, but I'll try anyway: the SlickEdit preprocessor code analysis is not the full value analysis that the C/C++ preprocessor does, it's more like a parametrized textual substitution process. So while the full C/C++ preprocessor may perform a whole sequence of macro substitutions and syntactic parsing with the objective of evaluating a final value (e.g. "0") for any preprocessor code statement, the SlickEdit process is much more textually oriented, with the objective of determining what kinds of language token are in the text being edited and using that information for code display, coloring, parameter completion, etc., etc. (Obviously this requires substantial syntactic analysis, but I think it's more fragmentary than the full C/C++ preprocessor.)

And all of this analysis has to be done within the constraints of a responsive editor program performance.
« Last Edit: July 04, 2017, 05:44:15 PM by mjdl »

Micha_1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: #if 0 commenting
« Reply #22 on: July 05, 2017, 05:29:14 AM »
Thanks for the info.
Regarding the editor responsiveness: I like the way it is implemented in eclipse.
You have to start a sync of the source code manually, but do not have to enter every single define.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: #if 0 commenting
« Reply #23 on: July 05, 2017, 12:51:06 PM »
Is there a way to show code as active/inactive based on the defines (automatically) generated in the selective display dialog?
I am testing SlickEdit Pro 2016 (v21.0.3.0 32-bit) and this does not seem to work - I have to manually add the defines in the C/C++ preprocessing dialog.
Why are these defines not synchronized?

Did you know you can directly edit usercpp.h yourself?

If you add the following code to a macro file and compile it, when you hit F12 with the selective display dialog open, the content of the defines edit box will be written into usercpp.h.  With some more work you could remove any existing defines for the current file and add the new ones.  If this looks useful let me know and I'll see if I can add the extra code if you can't do it yourself.

Code: [Select]
defeventtab _seldisp_form;

_seldisp_form.'F12'()
{
   _control ctldefines;
   _str mydef = ctldefines.p_text;
   int window_id = p_window_id;
   _str xfile = _mdi.p_child.p_buf_name;

   edit(_ConfigPath() :+ 'usercpp.h');
   bottom();
   insert_line("//File : " :+  xfile);
   insert_line(mydef);
   p_window_id = window_id;
}

Micha_1

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: #if 0 commenting
« Reply #24 on: July 05, 2017, 01:49:39 PM »
Okay, I can edit usercpp.h directly.
But - there is no automatic retagging - and retagging the workspace does not seem to work, so I always have to open the C/C++ preprocessing dialog, confirm the defines and confirm the "do you want to retag your workspace?" dialog from there.
And I have to undef every used, but not defined #define.
And usercpp.h is global, not per project or workspace.
Not very convenient.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: #if 0 commenting
« Reply #25 on: July 05, 2017, 01:56:58 PM »
From the help file

Quote
The usercpp.h file should only be used for #defines and #undefs® not #includes.

Each workspace may have a [workspace]_cpp.h file which can be used for the same purpose as usercpp.h, except that the configuration is for the corresponding workspace only. This file may be edited using the C/C++ Preprocessing dialog accessable from Project → Workspace Properties.