Recent

Author Topic: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?  (Read 4215 times)

Soner

  • Sr. Member
  • ****
  • Posts: 305
Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« on: April 22, 2019, 03:43:28 pm »
Is there for LCL compiler definition to gettting version number like this?
{$IF LCL_VERSION>2}

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #1 on: April 22, 2019, 03:51:56 pm »
Not exactly like this:

use LCL_FullVersion from unit LCLVersion, or Laz_FullVersion from unit LazVersion

e.g.: {$IF LCL_FullVersion > 2030106}  // 2.03.01.06

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #2 on: May 11, 2019, 11:30:17 pm »
Unfortunately, this doesn't work.

Entering {$if LCL_FullVersion >= 2000000} ends up in the error message

Code: Pascal  [Select][+][-]
  1. Error: Incompatible types: got "AnsiString" expected "Int64"
.

Obviously LCL_FullVersion isn't defined. The code after {$if Declared(LCL_FullVersion) and (LCL_FullVersion >= 2000000)} is never compiled.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #3 on: May 12, 2019, 12:01:04 am »
You must add the unit in which LCL_FullVersion is defined to "uses".
Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLVersion;
  3.  
  4. {$IF LCL_FullVersion >= 2000000}
  5.   {$DEFINE Something}
  6. {$IFEND}
 

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #4 on: May 12, 2019, 07:58:16 pm »
I've found that I need to CAPS the whole string..

{$IF FPC_FULLVERSION >= 30101}

If I don't caps the string the compiler fails on it with an error stating it is expecting a Ansi string.

I am doing this with 3.0.4 so that could be the difference.
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #5 on: May 15, 2019, 09:06:44 am »
I've found that I need to CAPS the whole string..

{$IF FPC_FULLVERSION >= 30101}

If I don't caps the string the compiler fails on it with an error stating it is expecting a Ansi string.

I am doing this with 3.0.4 so that could be the difference.
Are you sure that you didn't misspell it in the other cases? Cause it works here in any casing (as it should) with both 3.0.4 and trunk.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #6 on: May 15, 2019, 10:44:16 pm »
I've found that I need to CAPS the whole string..

{$IF FPC_FULLVERSION >= 30101}

If I don't caps the string the compiler fails on it with an error stating it is expecting a Ansi string.

I am doing this with 3.0.4 so that could be the difference.

Well, this is FPC_FULLVERSION. What is needed, however, is LCL_FULLVERSION. This still raises the type error, regardless of the case, in which the conditional is written.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

dsiders

  • Hero Member
  • *****
  • Posts: 1052
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #7 on: May 15, 2019, 11:33:57 pm »
I've found that I need to CAPS the whole string..

{$IF FPC_FULLVERSION >= 30101}

If I don't caps the string the compiler fails on it with an error stating it is expecting a Ansi string.

I am doing this with 3.0.4 so that could be the difference.

Well, this is FPC_FULLVERSION. What is needed, however, is LCL_FULLVERSION. This still raises the type error, regardless of the case, in which the conditional is written.

One more time...

You have to use the file that includes the version constants.

Case does not matter.

Try it.

Code: Pascal  [Select][+][-]
  1. uses
  2.   LazVersion,
  3.   LCLVersion;
  4.  
  5. { TForm1 }
  6.  
  7. procedure TForm1.Button1Click(Sender: TObject);
  8. begin
  9.  
  10. {$if laz_fullversion > 2000000}
  11. ShowMessage(IntToStr(laz_fullversion));
  12. {$endif}
  13. {$if LAZ_FULLVERSION > 2000000}
  14. ShowMessage(IntToStr(laz_fullversion));
  15. {$endif}
  16. {$IF lcl_fullversion > 2000000}
  17. ShowMessage(IntToStr(lcl_fullversion));
  18. {$ENDIF}
  19. {$IF LCL_FULLVERSION > 2000000}
  20. ShowMessage(IntToStr(lcl_fullversion));
  21. {$ENDIF}
  22.  
  23. end;
  24.  
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #8 on: May 15, 2019, 11:42:05 pm »
One more time...

You have to use the file that includes the version constants.

Yes, of course. But it doesn't work. Adding the uses clause with these units doesn't prevent this error message.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

dsiders

  • Hero Member
  • *****
  • Posts: 1052
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #9 on: May 15, 2019, 11:49:10 pm »
One more time...

You have to use the file that includes the version constants.

Yes, of course. But it doesn't work. Adding the uses clause with these units doesn't prevent this error message.

Alright then. Have fun with that.
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

wp

  • Hero Member
  • *****
  • Posts: 11855
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #10 on: May 16, 2019, 12:38:27 am »
Yes, of course. But it doesn't work. Adding the uses clause with these units doesn't prevent this error message.
When you paste the dsiders' EXACT code into a button OnClick handler do you still get the same error? I do not get any error message - this code snippet is working correctly, I checked back to Laz 1.8.4 (Win 10).

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #11 on: May 16, 2019, 02:23:51 am »
I checked back to Laz 1.8.4 (Win 10).

Actually, LazVersion didn't exist in 1.8.4, it was added in 2.0 (see https://bugs.freepascal.org/view.php?id=33418), but LCLVersion has been there for many years.

Anyway, jwdietrich's signature says he's version is 2.0.0.

And capitalization does not matter, of course. Dsiders' code works.
« Last Edit: May 16, 2019, 02:30:08 am by Zoran »

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #12 on: May 16, 2019, 03:20:16 am »
@PascalDragging

 Yes, I had to CAP the full string before it would work..

 I found some sample code that did work and that is what was done, just a all CAPS and it worked.
 
 Other combinations would report something like expecting some type but got Ansistring or the reverse.
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #13 on: May 16, 2019, 08:53:57 am »
@PascalDragging

 Yes, I had to CAP the full string before it would work..

 I found some sample code that did work and that is what was done, just a all CAPS and it worked.
 
 Other combinations would report something like expecting some type but got Ansistring or the reverse.
Then please post a full example that does not work. It works here as both me and others confirmed.

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: Compiler definiton for lcl like {$IF LCL_VERSION>2} ?
« Reply #14 on: May 16, 2019, 11:06:25 pm »
I can't make it happen in a simple program

I found this when redoing a DX12.DX12 unit..

the compiler was interpreting it as a string and making then all CAPS fixed it..

I don't know what to tell  you but I know the compiler was confused.

I'll get back to this when I open that project again but I know for a fact it was doing it.

Today at the moment with simple code it isn't...

Could be related to other units in the uses list.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018