Lazarus

Programming => LCL => Topic started by: jamie on March 13, 2019, 12:42:49 am

Title: How to get LAZARUS version within source code using compiler functions?
Post by: jamie on March 13, 2019, 12:42:49 am
as the title states, I need to obtain the version of Lazarus, not FPC in source code, is there any environment variables
Lazarus defines that can be queried via the {$IFDEF ….. } ?
Title: Re: How to get LAZARUS version within source code using compiler functions?
Post by: Wallaby on March 13, 2019, 01:34:46 am
{$IF LCL_FULLVERSION>=1000000} //for laz 1.0.0.0 (major,minor,release,patch)
{$IF LCL_FULLVERSION>=1000200} //for laz 1.0.2.0

or check the LazVersion unit, which contains something like

const
  laz_major = 2;
  laz_minor = 0;
  laz_release = 1;
  laz_patch = 0;
  laz_fullversion = ((laz_major *  100 + laz_minor) * 100 + laz_release) * 100 + laz_patch;
  laz_version = '2.0.1.0';

Title: Re: How to get LAZARUS version within source code using compiler functions?
Post by: jamie on March 13, 2019, 01:58:05 am
What I am looking for is a compiler define, one that has been set like this

{$DEFINE  Lazarus=1.8.4}

This would need to be global of course

The idea is the use compiler control to not compile in code or compile in different code depending on the
version I am running.

 The reason I want this is due to some issues existing in Lazarus now where it can be worked around but this
most likely will change later and then I could have it compile the proper code without making changes to the
source code.
Title: Re: How to get LAZARUS version within source code using compiler functions?
Post by: lucamar on March 13, 2019, 02:26:17 am
It's not really the Lazarus version. After all, Lazarus is just an IDE, i.e. an overgrown text-editor. ;) What really matters is the version of the LCL and you can get that with LCL_FULLVERSION. For example:

Code: Pascal  [Select][+][-]
  1.   {$IF (LCL_FULLVERSION < 1080400)}
  2.   ShowMessage('I''ll use workarounds for Lazarus pre-1.8.4');
  3.   {$ELSE}
  4.   Showmessage('Woah! Congrats! Lazarus is at least 1.8.4.0!')
  5.   {$ENDIF}
Title: Re: How to get LAZARUS version within source code using compiler functions?
Post by: PascalDragon on March 13, 2019, 09:45:44 am
What I am looking for is a compiler define, one that has been set like this

{$DEFINE  Lazarus=1.8.4}

This would need to be global of course
What Wallaby and lucamar posted is the correct approach. Though you need to add the LazVersion unit to your uses clause to be able to check for the constants using compiler directives (and it will only work after the whole uses clause is parsed).
Title: Re: How to get LAZARUS version within source code using compiler functions?
Post by: jamie on March 13, 2019, 09:51:23 pm
yes that is what I want. Thank you..
TinyPortal © 2005-2018