[Lazarus] Conditional compilation depending on Lazarus version?

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Mar 22 14:10:44 CET 2012


Sven Barth wrote:
> Am 22.03.2012 13:28, schrieb Mark Morgan Lloyd:
>> Sven Barth wrote:
>>> Am 22.03.2012 11:32, schrieb Reinier Olislagers:
>>
>>>> I realize that the code above will be compiled by FPC, not Lazarus;
>>>> perhaps it is possible to set an environment variable LAZARUSREVISION
>>>> and/or LAZARUSVERSION and get these into FPC macros in some way?
>>>
>>> The revision is not possible (when using development versions you
>>> should try to use the latest revision), but for version you can use
>>> the unit LCLVersion. Just add it to the uses clause and then you can
>>> use e.g.:
>>>
>>> {$if lcl_fullversion>=93100}
>>> // code that should work with 0.9.31 or newer
>>> {$endif}
>>
>> For the record, can you easily say what version of FPC introduced this
>> capability?
>>
> 
> According to a svn blame for the corresponding code this is in there at 
> least since 2005 (when FPC switched from CVS to SVN and thus no older 
> history is available to the public)

Which probably makes it safe for 2.2.4, which corresponds approximately 
to 0.9.24.1 by which time the new-format lcl_fullversion etc. were 
available.

I was looking at these versions a few days ago, because I've got one 
project which I'm trying to keep compatible with GTK v1. Being to base 
coding decisions relating to e.g. Synedit capabilities on Lazarus rather 
than FPC version, without having to go to RTTI, is obviously a major 
advantage.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list