Recent

Author Topic: Code tools greys out sections within a valid check of LCL or Laz version.  (Read 1043 times)

jamie

  • Hero Member
  • *****
  • Posts: 7601
uses lclVersion


{$IF LCL_FullVersion >= 2000000} //
 
  all code is greyed out but compiled in.

{$IFEND}
« Last Edit: May 12, 2024, 09:06:07 pm by jamie »
The only true wisdom is knowing you know nothing

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
If doing incorrect usage, strange things happen or does on your system my popup appear?
Code: Pascal  [Select][+][-]
  1.   {$IF Defined(FPC) and Declared(LCL_FullVersion) and (LCL_FullVersion >= 20000000)}
  2.     ShowMessage('I will never show on Windows.');
  3.   {$IFEND}
Lazarus 3.99 (rev main_3_99-1962-g0a7ff2fb3d) FPC 3.2.2 x86_64-win64-win32/win64

//edit
apologies, I just tested now your plain unchecked variant, it also works as expected that the popup not show.
very mysterious ...
« Last Edit: May 12, 2024, 07:26:30 pm by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

jamie

  • Hero Member
  • *****
  • Posts: 7601
I was hoping for someone to tell me what I have wrong in the IDE settings. :o

 It appears that the compiler knows the difference between but the IDE/EDITOR or maybe Code Tools can't figure it out.

  I believe it is due to a macro function in the LclVersion and lazVersion files that is causing this with the Editor.
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1556
I was hoping for someone to tell me what I have wrong in the IDE settings. :o

 It appears that the compiler knows the difference between but the IDE/EDITOR or maybe Code Tools can't figure it out.

  I believe it is due to a macro function in the LclVersion and lazVersion files that is causing this with the Editor.

lcl_fullversion is not a macro... it's a constant in lcl/lclversion.pas. The issue is that your code is using 8 digits... the constant uses 7.

jamie

  • Hero Member
  • *****
  • Posts: 7601
it does not matter; I can use 1 for a compare value.

it still fails.

If I compare with 0 then it does not grey out.

The compiler has no issue with this, it's the editor or code tools in laz that does.

The evidence is all over the source pages that has those checks, they all are greyed out, its not my code only.


I wanted to add, This looks like it has been around for some time now, it also fails in 3.0.4 laz.


« Last Edit: May 12, 2024, 09:07:54 pm by jamie »
The only true wisdom is knowing you know nothing

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
I just tested with the values of my version, the conditional goes in when compiled but in IDE its greyed out, probably because the connection is just available at runtime?
Code: Pascal  [Select][+][-]
  1. {
  2. laz_major = 3;
  3. laz_minor = 99;
  4. laz_release = 0;
  5. laz_patch = 0;
  6. laz_fullversion = ((laz_major *  100 + laz_minor) * 100 + laz_release) * 100 + laz_patch;
  7. lcl_fullversion = laz_fullversion;
  8. }
  9. {$IF Defined(FPC) and Declared(LCL_FullVersion) and (LCL_FullVersion = 3990000)}
  10.    ShowMessage('Why am I greyed out when the check for my version is valid?...');
  11. {$IFEND}
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Bart

  • Hero Member
  • *****
  • Posts: 5706
    • Bart en Mariska's Webstek
This is a know issue: codetools does not evaluate constants in {$if } statements.
There is already a bugreport about that.

Bart

 

TinyPortal © 2005-2018