Lazarus

Using the Lazarus IDE => General => Topic started by: kegge13 on October 23, 2020, 05:55:06 pm

Title: [SOLVED] code executable as expected but grayed out in editor
Post by: kegge13 on October 23, 2020, 05:55:06 pm
In my project-compiler-options include file this construc can be found:
{$DEFINE SelfTest}
{$IFOPT D-}
  {$UNDEF SelfTest}
{$ENDIF}
                       
So if not in debug mode, do not include selftest. This works fine, but still that part of the code is grayed out (LCL 2.0.10 on Windows) in debug mode. See small screen dump. I can set breakpoints in this code, introduce compiler errors etc.

Any suggestions?
Thanks in advance.
Title: Re: code executable as expected but grayed out in editor
Post by: lucamar on October 23, 2020, 06:41:53 pm
My guess, based on a quick test, is that the IDE is not parsing correctly the IFOPT directive and instead assumes "D-" as default, as shown in the attached image.

The most probable reason might be because it's a compiler directive and its default is, IIRC, that state (don't generate debugging info).
Title: [SOLVED] code executable as expected but grayed out in editor
Post by: kegge13 on October 24, 2020, 11:55:38 am
Thanks for pointing in the right direction.
I found this earlier topic: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Conditional-define-via-Build-mode-td3638027.html
and followd that line: add -dDEBUG as compiler option for debug mode.

Then I can check on that:
{$DEFINE SelfTest}
{$IFNDEF DEBUG}
  {$UNDEF SelfTest}
{$ENDIF}

Now my code looks (and works) as expected in both modes.
TinyPortal © 2005-2018