[Lazarus] Conditional compilation depending on Lazarus version?
Mark Morgan Lloyd
markMLl.lazarus at telemetry.co.uk
Sat Mar 24 20:46:22 CET 2012
Sven Barth wrote:
> On 24.03.2012 19:35, Mark Morgan Lloyd wrote:
>> As a variation of the latter, am I correct in saying that ifdef can't be
>> used to check whether a function or procedure is implemented in some
>> imported unit?
>>
>
> $ifdef does only work with defines (those done with -dXXX or {$define
> ...}), but not with identifiers/symbols (lcl_fullversion is a symbol).
> If you want to check for the existance of a symbol you need to use this:
>
> {$if declared(lcl_fullversion) }
> // code that should work with any version that defines lcl_fullversion
> {$endif}
> // Note: if you need Delphi compatibility you need to use {$ifend}
> instead of {$endif} here
Ah /ha/! So in other words I can use something like
{$if declared(SerGetRI) }
WriteLn('Has SerGetRI');
{$endif }
{$if declared(SerGetCD) }
WriteLn('Has SerGetCD');
{$endif }
to check whether the updated serial.pp that I attached to bug 18946 is
actually available, rather than having to scratch around looking for it
when I don't actually need to monitor CD.
--
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