[Lazarus] Conditional compilation depending on Lazarus version?

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Mar 22 20:25:49 CET 2012

cobines wrote:
> 2012/3/22 Mark Morgan Lloyd <markMLl.lazarus at telemetry.co.uk>:
>> At that point if there's an ./ide/revision.inc file containing
>> // Created by Svn2RevisionInc
>> const RevisionStr = '35880M';
>> can it be included into a unit to make it visible at compile time?
> You can add "$(LazarusDir)\ide" to the include paths of the project.
> Then this works:
> {$I revision.inc}
> const
>   revIntroducedNewFeature = '55555';
> begin
>   {$IF (RevisionStr >= revIntroducedNewFeature)}
>   UseNewFeature;
>   {$ENDIF}
> end;

True, although what I was really wondering was whether it could be 
pulled in purely by referencing a unit, rather than having $I all over 
the place. And there's still the issue of recovering gracefully if the 
include file isn't available or the version is non-numeric, i.e. has an 
appended M or reads "exported" because Lazarus wasn't built from SVN.

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